Error Handling in Scripts
Take precautions in your scripts to handle errors. Script syntax is checked when you save an object, but errors can occur due to other factors. There are several ways that you can include responses to errors in your scripts, such as canceling a script when an error or occurs or sending notifications to alert users.
This page includes the following:
Syntax Checking
When you save an object, the system checks the syntax of the script functions and script statements that you have written and prevents you from saving the object if it finds errors. The error message indicates the line number of the error.
Note: Only the script is checked. You must ensure that you write correct values such as object names.
Tip: The script editor includes several features such as syntax tooltips and autocompletion to assist you when writing scripts. For more information, see Working with the Script Editor.
Return Codes
Use the return codes of functions to evaluate whether the script has resulted in the desired outcome, and include script instructions that are processed conditionally based on the return code. For example, you can use scripts to generate notifications to users when a scripted step fails or results in another outcome that requires user attention.
For details on the possible return codes of each script function, see Automation Engine Script Reference.
Canceling a Script When an Error Occurs
Many script elements include options for canceling the script and displaying an error message when an error occurs during the execution of the script. For example, the ACTIVATE_UC_OBJECT script function lets you specify that script processing should be canceled in case of an error.
Not all script elements provide options for canceling the script and displaying an error message. If a particular script element does not include those options, you can use the :ON_ERROR script statement to specify what should happen when an error occurs. Script processing can either resume or be canceled. If script processing resumes, you can retrieve the error message with the SYS_LAST_ERR_NR or SYS_LAST_ERR_INS script functions.
More Information:
See also: