:ON_ERROR

Use the :ON_ERROR script statement to define what happens to script processing when a script element returns a particular error or message. Use it to allow script processing to continue when an error occurs — for example, to read return codes — or to abort the script. For more information on script functions you can use to analyze errors, see Script Elements for Error Handling.

Note: Some script elements allow you to define error behavior directly without requiring an :ON_ERROR statement.

Syntax

: ON_ERROR Reaction

Parameters

Parameter Description Format Allowed Values Default Value
Reaction Keyword defining the reaction to an error or message from a script element AE name, script literal, or script variable
  • RESUME — Script processing continues, allowing return codes to be read
  • ABEND — Script processing is aborted when an error occurs
RESUME

Important Considerations

You can use :ON_ERROR to define error handling for the following script functions and statements:

You can also use :ON_ERROR to handle errors in scripts with arrays that use an invalid index. For more information, see Arrays.

Note: By default, Automation Engine continues processing scripts that contain these script functions when an error occurs.

Examples

The following example specifies that script processing continues when an error occurs. The script checks the capacity of a drive and retrieves the error number and error message.

: ON_ERROR RESUME

: SET &CHECK# = GET_FILESYSTEM ('WIN21', 'Z:\\', FILESYSTEM_SPACE_TOTAL)

: SET &ERRNR# = SYS_LAST_ERR_NR ()

: SET &ERRINS# = SYS_LAST_ERR_INS ()

: SET &MESSAGE# = GET_MSG_TXT (&ERRNR#, &ERRINS#)

See also: