Handling Exceptions (WHEN … DO)
From InterBase
Go Up to WHEN … DO
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:
- Terminates execution of the
BEGIN … END
block containing the exception and undoes any actions performed in the block. - Backs out one level to the next
BEGIN … END
block and seeks an exception-handling (WHEN
) statement, and continues backing out levels until one is found. If noWHEN
statement is found, the procedure is terminated and all its actions are undone. - Performs the ensuing statement or block of statements specified after
WHEN
, if found. - Returns program control to the block or statement in the procedure following the
WHEN
statement.
- Note: An exception that is handled with WHEN does not return an error message.