When an exception occurs, the system default action in most cases is to end the application that caused the exception. Instead of having the system default action occur, an application can register its own exception handling routines. Exception handlers can be written to take corrective action so that a thread can continue running rather than being terminated by the system.

If an exception is handled by the application's exception handler, the exception handler must return XCPT_CONTINUE_EXECUTION. If the application's exception handler does not handle the exception, the exception handler must return XCPT_CONTINUE_SEARCH. If all the exception handlers in the exception handler chain return XCPT_CONTINUE_SEARCH, OS/2 takes the default action, which is usually to terminate the process that caused the exception.

Note: In the example code fragments that follow, error checking was left out to conserve space. Applications should always check the return code that the functions return. Control Program functions return an APIRET value. A return code of 0 indicates success. If a non-zero value is returned, an error occurred.