In this scenario, a C++ main
routine invokes a COBOL subroutine
and an exception occurs in the COBOL subroutine.
Refer to Figure 1 throughout the following
discussion.
Figure 1. Stack contents when the exception
occurs in COBOL
The actions taken follow the three Language Environment condition
handling steps: enablement, condition, and termination imminent.
- In the enablement step, COBOL determines
if the exception should be ignored or handled as a condition.
- If the exception is to be ignored, control is returned to the
next sequential instruction after where the exception occurred.
- If the exception is to be enabled and processed as a condition,
the condition handling step takes place.
- If a user-written condition handler was registered using CEEHDLR
on the COBOL stack
frame, it is given control. If it issues a resume, with or without
moving the resume cursor, the condition handling step ends. Processing
continues in the routine to which the resume cursor points. Note that
you must be careful when moving the resume cursor in an application
that contains a COBOL program.
See CEEMRCR and COBOL for details.
In
this example no user-written condition handler is registered for the
condition, so the condition is percolated.
- If a user-written condition handler was registered for the condition
using CEEHDLR on the C++ stack
frame, it is given control. If it issues a resume, with or without
moving the resume cursor, the condition handling step ends. Processing
continues in the routine to which the resume cursor points.
In
this example no user-written condition handler is registered for the
condition, so the condition is percolated.
- If a C signal handler was registered for the condition, it is
given control. If it moves the resume cursor or issues a call to longjmp(),
the condition handling step ends. Processing resumes in the routine
to which the resume cursor points.
In this example, no C signal
handler is registered for the condition, so the condition is percolated.
- If the condition has a Facility_ID of IGZ, the condition is COBOL-specific.
The COBOL default
actions for the condition take place. If COBOL does
not recognize the condition, condition handling continues.
- If the condition is of severity 0 or 1, Language Environment default
actions take place, as described in Table 1.
- If the condition is of severity 2 or higher, Language Environment default
action is to promote the condition to T_I_U (Termination Imminent
due to an Unhandled condition) and redrive the stack. Condition handling
now enters the termination imminent step.
- If on the second pass of the stack no condition handler moves
the resume cursor and issues a resume, Language Environment terminates
the thread.