Microsoft Foundation Classes (mfc.hlp) (
Table of Contents;
Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
CATCH Macro
◄Up► ◄Contents► ◄Index► ◄Back►
──Microsoft Foundation Classes──────────────────────────────────────────────
CATCH( exception_class, exception_object_pointer_name )
Parameter Description
<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►
-♦-