Share via


Exception Handling of Commerce Server 2002 BCL and PIA/COM Interop Objects

All calls to Commerce Server 2002 BCL objects will throw an exception if any error occurs. These errors could be of these types "CommerceException", or an exception derived from the System.Exception class.

It is recommended to call the Base Class Library (BCL) run time using a try-catch-finally block in the following manner:

  1. Gracefully handle specific exceptions of the BCL API calls used (for example ProductNotFoundException). By handling these exceptions the user will able get a graceful error message. The exception will not be rethrown.
  2. If the codepath expects to handle gracefully any other specific exceptions (for example, ArgumentNullException) it may use additional catch blocks to handle them. This will make certain that the error will not be passed to higher level event handlers that might interrupt the display of the page.
  3. If the exception is not handled as above, a general catch statement may be used to catch all other exceptions. You should then throw a new exception with the inner exception property set.

See Also

Exception Handling Guidelines and Best Practices

Copyright © 2005 Microsoft Corporation.
All rights reserved.