When a program executes, a number of abnormal conditions and errors called "exceptions" can occur. These may include running out of memory, resource allocation errors, and failure to find files.
The Microsoft Foundation Class Library uses an exception-handling scheme that is modeled closely after the one proposed by the ANSI standards committee for C++. An exception handler must be set up before calling a function that may encounter an abnormal situation. If the function encounters an abnormal condition, it throws an exception and control is passed to the exception handler.
Several macros included with the Microsoft Foundation Class Library will set up exception handlers. A number of other global functions help to throw specialized exceptions and terminate programs, if necessary. These macros and global functions fall into the following categories:
Exception macros, which structure your exception handler.
Exception-throwing functions, which generate exceptions of specific types.
Termination functions, which cause program termination.
For examples and more details, see the article Exceptions.
Designates a block of code for exception processing.
Designates a block of code for catching an exception from the preceding TRY block.
Designates a block of code for catching all exceptions from the preceding TRY block.
Designates a block of code for catching additional exception types from the preceding TRY block.
Designates a block of code for catching all other additional exception types thrown in a preceding TRY block.
Ends the last CATCH or AND_CATCH code block.
Ends the last CATCH_ALL code block.
Throws a specified exception.
Throws the currently handled exception to the next outer handler.
Throws an archive exception.
Throws a file exception.
Throws a memory exception.
Throws a not-supported exception.
Throws a Windows resource-not-found exception.
Throws an exception in a user-initiated program action.
MFC provides two exception-throwing functions specifically for OLE exceptions:
Throws an exception within an OLE automation function.
Throws an OLE exception.
To support database exceptions, the database classes provide two exception classes, CDBException and CDaoException, and global functions to support the exception types:
Throws a CDaoException from your own code.
Throws a CDBException from your own code.
MFC provides the following termination function:
Called to terminate an application when a fatal error occurs.