In the following example, all ERROR conditions would be handled in the begin-block, the FINISH condition would be handled by the system, and all other conditions would be handled by the call to the routine named handle_All_Others.
on error begin;
·
·
·
end; on finish system; on anycondition call Handle_all_others;
Note that when a condition is raised, the call stack will be walked (backwards) to search for a block that has an ON-unit for that condition. The search will stop when the first block with such an ON-unit or with an ON ANYCONDITION ON-unit is found. If no such ON-units are found and the implicit action for the condition is to promote it to ERROR, the stack will then (and only then) be walked again to search for an ON ERROR ON-unit.
You can use the ONCONDID built-in function in an ANYCONDITION ON-unit to determine what condition is being handled, and the ONCONDCOND built-in function to determine the name of the CONDITION condition. Other ON built-in functions, such as ONFILE, can be used to determine the exact cause and other related information. These built-in functions are listed in Built-in functions, pseudovariables, and subroutines..
|