Scenario 3 is much the same as scenario 2, except that routine
B has a user-written condition handler established to handle the divide-by-zero
condition. Refer to Figure 1 throughout
the following scenario.
Figure 1. Scenario 3:
Division by zero with a user handler present in routine B
The handler established by routine B is designed to deal with divide-by-zero
and possibly other conditions that occur either during its execution
or in the routines that it calls. For a divide-by-zero condition,
the handler is to print a message and continue processing.
- A divide-by-zero exception occurs in routine B.
- The divide-by-zero exception is enabled by the language of the
stack frame in which it occurred because it is a problem that, if
it remains unhandled, causes termination.
- The following occurs in the condition step:
- If a user-written condition handler has been registered using
the CEEHDLR callable service on routine B's stack frame, it is given
control. The handler recognizes the divide-by-zero as a condition
it is capable of dealing with. It produces a message, does appropriate
clean-up, and then causes resumption either through HLL constructs
or Language Environment services.
- The condition is now considered to be handled and is never seen
by stack frame A or the Language Environment default
handler.