

Description:
The ERROR built-in returns the keyword of the last error. This data is
normally only used in error-handling routines.
Syntax:
keyword := ERROR
Example:
ERR$KEY := ERROR;
IF ERR$KEY = TPU$_NOCACHE THEN
QUIT;
ENDIF;
Caveats/Bugs:
ERROR under VAX/VMS is a language element defined and behaving like a built-in
procedure. Under nu/TPU, ERROR is a built-in only.
Error Handlers:
An error handler is a block of code containing statements to be executed if
nu/TPU generates a warning or an error. Error handlers are optional and may be
used either in procedures or in programs. When used in programs (outside
procedures) they must be placed after all the global declarations of constants,
variables and procedures, and before any executable statements. Only one error
handler can be used in each procedure, and only one one can be used per program
(outside procedures).
nu/TPU error handlers are not usually recursive; that is, they do not apply
their own statements to errors that arise while the error handler itself is being
executed. However, CTRL/C routines are an exception; they ARE recursive.
Types of Error Handlers in nu/TPU
nu/TPU has two types of error handlers: procedure-style and case-style.
The following example shows the syntax of a procedure-style error handler:
ON_ERROR
MESSAGE (ERROR_TEXT);
MESSAGE ("Error on line " + STR (ERROR_LINE));
RETURN;
ENDON_ERROR
The following example shows the syntax of a case-style error handler:
ON_ERROR
[TPU$_CONTROLC]:
MESSAGE (ERROR_TEXT);
RETURN (LEARN_ABORT);
[OTHERWISE]:
MESSAGE( ERROR_TEXT);
RETURN;
ENDON_ERROR
Case-style error handlers are similar to nu/TPU case statements. The
statements in the handler have the general format:
[error-keyword 1,...error-keyword n] : statement 1;...statement n;
The selectors on the left-hand side of the colon in each statement must be
either of the following:
Case-style error handlers allow you to do the following:
Related Builtins:
ERROR
nu/TPU error or warning keywords
The keyword OTHERWISE
Trap the TPU$_CONTROLC status
Specify an [OTHERWISE] selector specifying how to handle all errors and
warnings that are not covered by specific selectors in the error handler.
Suppress display of error and warning messages