Onerrgo

Use Onerrgo to set up a branch label used if an error is thrown.

Syntax

 OnerrgoOnerrgo LABELOnerggo LABEL From SCRIPT

Examples

 # Open a file, and handle the errorERROR_FLAG=0# OPEN_ERROR is the label used if the file cannot be opened (in a dedicated script ERRMGT)Onerrgo OPEN_ERR From ERRMGT# Let's open the fileOpeni filpath("TXT","TEST","txt")If ERROR_FLAGEndEndif# No more error management hereOnerrgo...End# Extract of the ERRMGT script$OPEN_ERRORERROR_FLAG=errnERROR_MSG=errmes$(errn)Resume

Description

Onerrgo allows you to define a label where a branch is done when an error is thrown by the engine. When an error happens, the script lines following the label are executed. In this script:

If a new error is thrown in the error handling script, no error rerouting is executed again to avoid infinite loops.

The error routine can terminate by using one of the following statements:

Onerrgo, without label, disables the routing on error. After this instruction, an error interrupts the script and displays the error.

Comment

When a transaction started by Trbegin provokes an error while in progress, the error handling script cannot Commit or Rollback the transaction. This must be done in the original program. However, if the error handling script reaches an End statement, an automatic Rollback of the transaction is performed.

An Onerrgo declaration in a script remains valid until the script ends or another Onerrgo statement is encountered. The execution of the error routing causes the suspension of an Onerrgo effect until the Resume instruction is encountered.

When a script invokes a routine by Call where no Onerrgo instruction is required, an error encountered during the call stops the script execution while the error script takes over as if the error was encountered on the Call line. If the errors have to be handled in the nested call, it is important to use Onerrgo in the called script.

Associated errors

Error codeDescription
10The expression that gives the script name does not return a string value.
20The script does not exist.
39The label does not exist. This happens only at execution time if the label is located in another script; otherwise, it is detected at script compilation.

See also

End, Resume, errn, errl, errp, errmes$, errm, Call.