User-Written Error Handling Routines

You can handle most error conditions that might occur when a program is running by using the ON EXCEPTION phrase, the ON SIZE ERROR phrase, and other ILE COBOL language semantics. But in the event of an extraordinary error condition like a machine check, ILE COBOL will issue an inquiry message to allow you to determine what action should be taken after a severe error has occurred.

However, ILE COBOL, in conjunction with ILE provides a mechanism, through user-written ILE condition handlers, whereby extraordinary error conditions can be handled prior to issuing an inquiry message. ILE condition handling gives you the opportunity to write your own error-handling routines to handle error conditions which can allow your program to continue running.

User-written condition handlers have priority level 165. This priority level enables user written condition handlers a chance to see signalled conditions before input-output condition handlers or ILE debugger condition handlers.

In order to have ILE pass control to your own user-written error-handling routine, you must first identify and register its entry point to ILE. To register an exception handler, you pass a procedure-pointer to the Register in a User-Written Condition Handler (CEEHDLR) bindable API. If you want to use an ILE COBOL program as an exception handler, only the outermost ILE COBOL program can be registered. Since ILE COBOL does not allow recursion for non recursive programs, if you register an ILE COBOL program as an exception handler, you must ensure that it can only be called once in an activation group, or that it is a recursive program.

Refer to ILE Concepts for more information on exception handlers. Procedure-pointer data items allow you to pass the entry address of procedure entry points to ILE services. For more information on procedure-pointer data items, see Passing Entry Point Addresses with Procedure-Pointers. Any number of user-written condition handlers can be registered. If more than one user-written condition handler is registered, the handlers are given control in last-in-first-out (LIFO) order.

User-written condition handlers can also be unregistered with the Unregister a User-Written Condition Handler (CEEHDLU) API.