This section describes error handling facilities supported in VBScript. Rules are provided to turn of and off the error handling flag, and to inspect 'Err' object properties.
VBScript offers some limited facilities to help your manage runtime errors.
Here is a summary of rules that will help you to properly manage runtime errors in your VBScript code:
1. The "On Error Resume Next" statement can be used to turn on the error handling flag.
2. The "On Error GoTo 0" statement can be used to turn off the error handling flag.
3. User defined procedures have their own error handling flags.
This means that each user defined procedure should be have its own
"On Error Resume Next" or "On Error GoTo 0" statement to turn on or off its own error handling flag.
4. By default, error handling flags of all user defined procedures and the main code are turned off.
5. By default, the host environment provides a built-in object called "Err" to hold runtime error information.
6. When a runtime error occurs, the host environment will set values to properties of the "Err" object
and raise a runtime error.
7. When a runtime error is raised and the current error handling flag is on,
the host environment will continue to execute the next statement.
8. With the error handling flag turned on, you can inspect "Err" object properties
to determine how to handle the error and continue your code execution.
9. When a runtime error is raised in a procedure and the current error handling flag is off,
the host environment will stop executing the procedure, transfer execution control to the calling code,
and raise the same runtime error in the calling code.
10. When a runtime error is raised in the main code and the current error handling flag is off,
the host environment will stop executing the main code, and take some additional steps.
11. When Internet Explorer (IE) gets a runtime error with the error handling flag turned off,
it will display small dialog box, if its script debug option is turned on.
12. When Windows Script Host (WSH) gets a runtime error with the error handling flag turned off,
it will print out an error message.