Error Handling |
Top Previous Next |
×V4.0Ø
There are a number of errors that cannot be anticipated and prevented such as a network outage or a failed update to a database. EMUE's error handling, new to version 4, provides more control to the user by allowing recovery from errors within the script. The OnError command determines what happens after an error occurs. Once the OnError line is run, it stays in effect until another OnError command is processed. That is, at the point when the OnError command is encountered, EMUE records the action that is set with OnError. Nothing else happens until an error is encountered. When an error is encountered, the instructions defined by the OnError take effect.
Upon encountering an error, if OnError GoTo is in effect, the script will continue execution at another point in code specified by the label following the GoTo. This section of code can use the information stored in &ErrorCategory and &ErrorNumber to determine what should happen depending on what the error is. The &ErrorCategory corresponds to the particular command that erred and the &ErrorNumber indicates the specific error that occurred. Information regarding the error is automatically logged to the activity log file.
Once the error has been handled in code, the Resume command will cause script execution to continue. This command can cause the script to retry the line that caused the error (Resume), continue at the line following the error (Resume Next), or continue execution after any label (Resume [Label]). OnError ExitError will discontinue error handling and cause EMUE to behave as if it had not encountered an OnError command. No error handling means that EMUE will respond to errors just like it would an ExitError statement - by exiting and sending an error email.
Alternatively, OnError Resume Next causes the script to ignore the line that erred and continue execution on the following line. This solution works best if the line that erred is not crucial to the success of the script.
|