Exceptions can also be defined by the application. These are called user-defined exceptions (as opposed to system-defined exceptions, which are those exceptions defined by OS/2). Applications can define an exception in the following fashion:
#define XCPT_YOUR_EXCEPTION 0xE004ABCD
The application then raises the exception, using DosRaiseException:
EXCEPTIONREPORTRECORD ERepRec; ERepRec.ExceptionNum = XCPT_YOUR_EXCEPTION; ERepRec.fHandlerFlags = 0; ERepRec.NestedExceptionReportRecord = NULL; ERepRec.ExceptionAddress = NULL; ERepRec.cParameters = 0; DosRaiseException(&ERepRec);The exception handlers in the exception handler chain that are ahead of the application's exception handler will see the exception, but they will not recognize it, so they will return XCPT_CONTINUE_SEARCH. Only the application's exception handler will recognize the exception.
The application's exception handler must return XCPT_CONTINUE_EXECUTION so that the exception will not continue to be passed down the exception handler chain.