All OS/2 exception handlers conform to the prototype for MyExceptHandler shown below. You can use such a handler alone, or with the VisualAge C++ default handler, _Exception.
#define INCL_BASE
#include <os2.h>
APIRET APIENTRY MyExceptHandler(EXCEPTIONREPORTRECORD *,
EXCEPTIONREGISTRATIONRECORD *,
CONTEXTRECORD *,
PVOID dummy);
The structures passed as parameters are updated by OS/2 and provide your function with information about the exception. They are defined in the OS/2 header file <bsexcpt.h>, located in the IBMCPP\INCLUDE\OS2 directory.
The types and linkage convention used in the prototype are as follows:
| Keyword | Description |
|---|---|
| APIRET | Specifies the return type
of the function. If you return from your exception
handler, you must return one of the following two values:
XCPT_CONTINUE_SEARCH indicates that the exception has not been handled and tells the operating system to pass the exception to the next exception handler. XCPT_CONTINUE_EXECUTION indicates that the exception condition has been corrected and tells the operating system to resume running the application using the information in the CONTEXTRECORD. |
| APIENTRY | Defines the function
linkage. The OS/2 header files found in the
IBMCPP\INCLUDE\OS2 directory header files define APIENTRY
as _System linkage. Use the APIENTRY keyword rather than
specifying the linkage type yourself. Note that your
exception handler must be an external function; it cannot be static. |
| EXCEPTIONREPORTRECORD * | Points to a structure that contains high-level information about the exception. |
| EXCEPTIONREGISTRATIONRECORD * | Points to the record that registered the exception handler. The address of the record is always on the stack. |
| CONTEXTRECORD * | Points to a structure
that contains information about the state of the thread
at the time of the exception, including the register
contents and the state of the floating-point unit and
flags. When an exception handler returns XCPT_CONTINUE_EXECUTION, the machine state is reloaded from this structure. You should only modify the contents of this structure if you are sure your exception handler will return XCPT_CONTINUE_EXECUTION. |
| PVOID | Is a pointer to void that you must pass back unchanged to the operating system. |
![]()
Write or Register an Exception
Handler
Register an Exception Handler Using
OS/2 APIs
Register an Exception Handler
Using Preprocessor Directives
![]()
OS/2 Exceptions and Default Handling
Exception
Information Provided by OS/2
OS/2 APIs That
Interfere with Exception Handling
