Getting Error Information

The Error object contains information about error conditions that arise while using the ScriptControl. Table 13.4 lists the properties and methods for the Error object.

Table 13.4: Error Object Properties and Methods

Property/Method Description
Clear method Clears the script error
Column property Contains the source code column number where the error occurred
Description property Describes the error
HelpContext property Contains a help context reference describing the error
HelpFile property Contains a help filename containing the help file context
Line property Contains the source code line number where the error occurred
Number property Contains the error number
Source property Describes the general type of error
Text property Contains the line of source code where the error occurred

The Source property describes the error as a runtime or compile-time error and the language as VBScript or JScript. The Text property contains the line of source code where the error condition was found. The Line and Column properties contain the exact location of the error in the script. The actual error number is available in the Number property, and the standard description of the error is in the Description property.

If you want to provide your users with a more detailed explanation, you can use the CommonDialog control with the HelpContext and HelpFile properties to display the Visual Basic help page for that error. (Note that you will need to install the associated help file on your system for this to work.)

The Clear method is used to reset the Error object. Using the AddCode, Eval, ExecuteStatement, or Reset methods will also clear the Error object before these methods begin processing. For more information about error handling, see Chapter 20.

© 1998 SYBEX Inc. All rights reserved.