AND_CATCH

Defines a block of code for catching additional exception types thrown in a preceding TRY block.

AND_CATCH(exception_class, exception_object_pointer_name )

Parameters

  • exception_class
    Specifies the exception type to test for. For a list of standard exception classes, see class 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 AND_CATCH block. This variable is declared for you.

Remarks

Use the CATCH macro to catch one exception type, then the AND_CATCH macro to catch each subsequent type. End the TRY block with an END_CATCH macro.

The exception-processing code can interrogate the exception object, if appropriate, to get more information about the specific cause of the exception. Call the THROW_LAST macro within the AND_CATCH block to shift processing to the next outer exception frame. AND_CATCH marks the end of the preceding CATCH or AND_CATCH block.

Note

The AND_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. This also applies to the exception_object_pointer_name variable.

Example

See the example for CATCH.

Requirements

Header: afx.h

See Also

Reference

TRY

CATCH

END_CATCH

THROW (MFC)

THROW_LAST

AND_CATCH_ALL

CException Class

Concepts

MFC Macros and Globals