NET/MASTER Network Control Language (NCL) Programmer's Guide
Writing an Error Handler
Run-Time Error Handling
106160 Tandem Computers Incorporated 7–5
System-Defined Error Handlers for Specific Conditions
There are various system-defined error handlers for specific conditions. Specific
system-defined error handlers are specified by ON statements such as the following:
ON ARITH_ERROR
statement
/* Processes arithmetic errors */
ON LABEL_ERROR
statement
/* Processes label errors */
ON RANGE_ERROR
statement
/* Processes range errors */
ON TYPE_ERROR
statement
/* Processes type mismatch errors */
ON VERB_ERROR
statement
/* Processes verb errors */
If present, a system-defined error handler is automatically raised by NCL when it
detects an error. All individual system-defined error handlers for specific conditions
are described in detail later in this section.
User-Defined Error Handlers
You can define your own error handler as follows:
ON MY_ERROR
statement
/* Processes user-defined errors */
NCL does not automatically raise a user-defined error handler; you must use the
SIGNAL core statement to do so:
SIGNAL MY_ERROR
Using More Than One Error Handler
You can use more than one error handler to trap errors. The following example shows
three error handlers in a block of statements bound by the PROCEDURE and END
core statements—the ERROR error handler, the ARITH_ERROR error handler, and the
TYPE_ERROR error handler:
proc_label: PROCEDURE
ON ERROR
statement
ON ARITH_ERROR DO
statement1
statement2
statement3
…
END
ON TYPE_ERROR DO
statement1
statement2
statement3
…
END
…
END proc_label
The example traps arithmetic errors in the ARITH_ERROR error handler, type errors
in the TYPE_ERROR error handler, and all other errors in the ERROR error handler.
The error handlers are positioned so that they are executed immediately after the first
statement in the procedure—proc_label: PROCEDURE.