Exceptions can be nested. A nested exception is an exception that occurs while another exception is being handled. When this happens, the processing of the first exception is temporarily suspended. Exception handling begins again with the most recently generated exception.
Example:
The following example shows a nested exception.
Figure 184. ILE C Source to Nest Exceptions
|
In this example, the main() function generates an exception which causes main_hdlr to get control. The handler main_hdlr generates another exception which causes hdlr_hdlr to get control. The handler hdlr_hdlr handles the exception. Control resumes in main_hdlr, and it handles the original exception.
As this example illustrates, you can get an exception within an exception handler. To prevent exception recursion, exception handler call stack entries act like control boundaries with regards to exception percolation. Therefore it is recommended that you monitor for exceptions within your exception handlers.
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.