Figure 1 and the following examples provide an illustration of how user-written condition handlers can handle conditions such as a divide-by-zero in a C, C++, COBOL, or PL/I application. In the C or C++ examples in C or C++ handling a divide-by-zero condition, the COBOL examples in COBOL handling a divide-by-zero condition, and the PL/I examples in PL/I handling a divide-by-zero condition, the main routine calls CEEHDLR to register the user-written condition handler (USRHDLR program (COBOL) for COBOL). The main routine then calls the DIVZERO routine (Figure 1 for COBOL), in which a divide-by-zero exception occurs.
Divide-by-zero is enabled as a condition in the following steps:
For simplicity, the examples shown in this topic do not include calls to some Language Environment services that could also be useful for handling conditions in your application. For example, you might code in the USRHDLR routine a call to the CEE3GRN callable service in order to get the name of the routine that incurred the condition.