NET/MASTER Network Control Language (NCL) Programmer's Guide
Scope and Error Handling
Run-Time Error Handling
106160 Tandem Computers Incorporated 7–17
Scope and Replacing an
Error Handler
If they are in the same block, you can replace an existing error handler with another
error handler that handles the same condition by running through the code of the new
error handler.
In the following example, the second ON ERROR routine replaces the preceding ON
ERROR routine because both are in the same block; and the second ON
ARITH_ERROR routine replaces the preceding ON ARITH_ERROR routine because
both are in the same block:
proc: PROCEDURE
ON ERROR CALL GENERROR
ON ARITH_ERROR CALL ARITHERR
…
ON ERROR CALL NEW_E /* Replaces preceding ON ERROR */
…
ON ARITH_ERROR CALL NEW_A/* Replaces preceding */
/* ON ARITH_ERROR */
…
END proc
An error handler for a certain condition in an outer block is not within scope if an error
handler for the same condition is established in a nested block. This means that when
the nested block terminates, the error handler for that block terminates as well. The
error handler in the outer block is reinstated as the current error handler. This is called
stacking error handlers—an error handler in an outer block is stacked pending the
termination of the nested block.
The following example has three blocks. One block is established by the NCL
procedure, PROC. The second block is established by the function, FUNC. The third
block is established by the DO loop, LOOP. Each block establishes its own ON
ERROR error handler. When a block terminates, its error handlers terminate too.
proc: PROCEDURE
ON ERROR CALL GENERR
…
func: FUNCTION
ON ERROR CALL GENERR1
…
loop: DO
ON ERROR CALL GENERR2
…
END loop
/* DO loop error handler terminates here */
/* Function error handler reestablished here */
…
END func
/* Function error handler terminates here */
/* Procedure error handler reestablished here */
…
END proc