NET/MASTER Network Control Language (NCL) Programmer's Guide

Setting an Error Handler
Run-Time Error Handling
7–14 106160 Tandem Computers Incorporated
Setting an Error
Handler
After you have written an error handler, the NCL process must then set it by running
through the code containing the ON statement(s) without any errors occurring. The
simplest way to do this is execute all ON statements as soon as the NCL procedure
begins execution. The following example runs through three error handlers—ERROR,
ARITH_ERROR, TYPE_ERROR—before other statements are executed:
proc_label: PROCEDURE
/* Runs through code at beginning */
ON ERROR
statement
ON ARITH_ERROR DO
statement1
statement2
statement3
END
ON TYPE_ERROR DO
statement1
statement2
statement3
END
END proc_label
If no error handler exists when an error occurs, NCL displays a run-time error
message and terminates the execution of the NCL process. If you have written an
error handler but the NCL process does not set it before an error occurs, the default
action taken by NCL is to terminate execution of the NCL process.
All the preceding examples in this section correctly set their respective error handlers;
the following example, however, does not. An invalid division operation does not
raise the error handler because the error handler is not set before an error occurs:
zex0708n: PROCEDURE
/* Bad error handler position. An invalid division */
/* operation does not raise the error handler because */
/* it is not set before an error occurs. */
SAY &1" divided by "&2" is "&1/&2
SAY Normal termination
ON ERROR DO
SAY "Condition is "&SYS.ERROR.COND
SAY "Code is "&SYS.ERROR.CODE
SAY "Line is "&SYS.ERROR.LINE
SAY "Column is "&SYS.ERROR.COLUMN
SAY "Error text is "&SYS.ERROR.TEXT
SAY "Statement is "&SYS.ERROR.STMT
SAY "Proc/Func is "&SYS.ERROR.PROCNAME
EXIT
END
END zex0708n