Exception handling

You can use three different kinds of exception handlers when running C programs in a CICS TS environment: CICS exception handlers, z/OS® Language Environment® abend handlers, and C exception handlers. If you are using C++, you can use any of these three, or the C++ exception handling approach using try, throw, and catch. When a CICS condition is not handled under C++, the behavior of constructors and destructors for objects is undefined.

If the CICS command EXEC CICS HANDLE ABEND PROGRAM(name) was specified in the application, it will be called for any program exception that occurs (such as an operation exception or a protection exception) as well as for any EXEC CICS ABEND ABCODE(...) command that is run.

z/OS Language Environment provides facilities to set up a user handler. These facilities are discussed in detail in z/OS Language Environment Programming Guide.

In CICS TS, the C error handling facilities have almost the same behavior as discussed in Handling error conditions, exceptions, and signals. A signal raised with the raise() function is handled by its corresponding signal handler or the default actions if no handler is installed. If a program exception such as a protection exception occurs, it is handled by the appropriate C handler if no CICS or z/OS Language Environment handler is present.

When a C or C++ application is invoked by an EXEC CICS LINK PROGRAM(...), the invoked program inherits any handlers registered by EXEC CICS HANDLE ABEND PROGRAM(...) in the parent program. Any handlers registered in the child override the inherited handlers. C signal handlers are not inherited.

The following chart shows the process for handling abends in CICS TS.