SETERR
Set Error Branch
This directive transfers program execution to a specified program line number or label if an error occurs during execution. The error-branching I/O options (ERR=, DOM=, END=) take precedence over the SETERR directive.
Syntax
Section titled “Syntax”SETERR line-ref
SETERR OFF
SETERR ONline-ref- is the program line number or label to branch to when an error is produced during program execution.
Remarks
Section titled “Remarks”This directive must appear in the program before any errors it is expected to handle.
SETERR processing can be turned off with SETERR OFF; it can be resumed with SETERR ON. This enables you to skip pieces of code that do not require error processing through the SETERR directive.
A SETERR 0 can be used to disable the SETERR branch.
When a SETERR branch is processed, the SETERR is automatically set to SETERR 0 and the previous SETERR value and the statement that developed the error are saved in case the RETRY directive is used. Any further errors that develop are handled based on SETERR 0 being in force unless another SETERR directive is executed. If an error branch (ERR=, END=, DOM=) is specified within the routine specified by the SETERR directive, the previous SETERR and RETRY addresses are lost if any of these error branches are taken.
SETERR is reset to 0 when a BEGIN, CLEAR, END, LOAD, RESET, RUN, or STOP directive is executed. SETERR is also reset to 0 when a SETERR branch is processed, until a RETRY directive is executed, which sets SETERR back to its status before the error condition arose.
The most recent SETERR specified completely overrides any previous setting, including the saved SETERR value that is used by the RETRY directive. SETERR should not be used in a nested error processing routine that has been activated by a previous SETERR branch.
Examples
Section titled “Examples”SETERR 08000If any error occurs that is not handled by an error-branching I/O option, program control is transferred to line 08000.
See also
Section titled “See also”RETRY, RETURN, and SETESC directives
ERR system variable
From the Thoroughbred Basic Language Reference, Volume III: R–Z, version 8.9.1. Open this page in the PDF