Write or Register an Exception Handler

To write an exception handler, you must use operating system-specific APIs, and conform to the prototype required by the operating system.

See system documentation for details on writing Windows exception handlers.

You can register an exception handler in two ways: using an OS/2 API, or using preprocessor directives.

When you register a handler using #pragma handler, the chain is updated for you and the following tasks, that you would otherwise have to code using APIs, are done automatically:

Calling OS/2 APIs gives you more flexibility than using #pragmas. Use this method when you want to:

If you register your own exception handler, the exceptions you handle are not seen by a signal handler. The exceptions you do not handle are passed to the next exception handler. If the next handler is the IBM C and C++ Compilers default handler, _Exception, it converts the exception to a signal and calls the appropriate signal handler.



Signals and Exceptions
Signal and Exception Handling


Register an Exception Handler Using Preprocessor Directives
Register an Exception Handler Using OS/2 APIs


Example of an OS/2 Exception Handler
Prototype of an OS/2 Exception Handler
Signal and Exception Handling Considerations