Go Up to Handling Errors
Instead of terminating when an exception occurs, a procedure can respond to and perhaps correct the error condition by handling the exception. When an exception is raised, it does the following:
- Seeks a
WHENstatement that handles the exception. If one is not found, it terminates execution of the
BEGIN … ENDblock containing the exception and undoes any actions performed in the block.
- Backs out one level to the surrounding
BEGIN … ENDblock and seeks a
WHENstatement that handles the exception, and continues backing out levels until one is found. If no
WHENstatement is found, the procedure is terminated and all its actions are undone.
- Performs the ensuing statement or block of statements specified by the
WHENstatement that handles the exception.
- Returns program control to the block in the procedure following the
- Note: An exception that is handled does not return an error message.