Home | Categories | Alphabetical | Classes | All Contents | [ < ] | [ > ]

Controlling Errors Using ON_ERROR


The ON_ERROR procedure determines the action taken when an error is detected inside a user procedure or function and no error handlers established with the CATCH procedure are found. The possible options for error recovery are shown in the following table:

Value
Action
0
Stop immediately in the context of the procedure or function that caused the error. This is the default action.
1
Return to the main program level and stop.
2
Return to the caller of the program unit that called ON_ERROR and stop.
3
Return to the program unit that called ON_ERROR and stop.

One useful option is to use ON_ERROR to cause control to be returned to the caller of a procedure in the event of an error. The statement:

ON_ERROR, 2 

placed at the beginning of a procedure will have this effect. Include this statement in library procedures and other routines that will be used by others once the routines have been debugged. This form of error recovery makes debugging a routine difficult because the routine is exited as soon as an error occurs; therefore, it should be added once the code is completely tested.

Note that error handlers established by CATCH supersede calls to ON_ERROR made in the same procedure.


Home | Categories | Alphabetical | Classes | All Contents | [ < ] | [ > ]