CATCH Macro

Syntax

CATCH( exception_class,exception_object_pointer_name )

Parameters

exception_class

The specific exception type to test for. For a list of standard exception classes, see CException.

exception_object_pointer_name

A name for an exception object pointer that will be created by the macro. You can use the pointer name to access the exception object within the CATCH block.

Remarks

Defines a block of code for catching the first exception type thrown in a preceding TRY block. The exception-processing code can interrogate the exception object, if appropriate, to get more information about the specific cause of the exception. Invocation of the THROW_LAST macro shifts processing to the next outer exception frame.

Note:

The CATCH block is defined as a C++ scope (delineated by curly braces). If you declare variables in this scope, remember that they are accessible only within that scope.

If exception_class is CException, then all exception types will be caught. You can use CObject::IsKindOf to determine which specific exception was thrown. A better way to catch several kinds of exceptions is to use sequential AND_CATCH statements, each with a different exception type.

Note:

The exception object is created by the macro. You do not need to declare it yourself.

See Also

TRY, AND_CATCH, END_CATCH, THROW, THROW_LAST