Skip to main content

Error Traps within Procedures

Error Traps within Procedures

If an error trap gets set from within a procedure, it needs to be directly to a private label in the procedure. (This is unlike in legacy code, where it can contain +offset or a routine name. This rule is consistent with the idea that executing an error trap essentially means unwinding the stack back to the error trap and then executing a GOTO.)

If an error occurs inside a procedure, $ZERROR gets set to the procedure label+offset, not to a private label+offset.

To set an error trap, the normal $ZTRAP is used, but the value must be a literal. For instance:

 SET $ZTRAP = "abc"
 // sets the error trap to the private label "abc" within this block

For more information on error traps, see Using Try-Catch.

FeedbackOpens in a new tab