VBScript » Objects » Err

Version: 1.0

The Err object holds information about the last runtime error that occured. It is not necessary to create an instance of this object; it is intrinsic to VBScript. Its default property is Number, which contains an integer representing a VBScript error number or an ActiveX control Status Code (SCODE) number. This value is automatically generated when an error occurs and is reset to zero (no error) after an On Error Resume Next statement or after using the Clear method.

Examples

Code:
<%
dim numerr, abouterr
On Error Resume Next
Err.Raise 6
numerr = Err.number
abouterr = Err.description
If numerr <> 0 Then
Response.Write "An Error has occured! Error number " numerr " of the type '" abouterr "'."
End If
%>
Output:
"An Error has occured! Error number 6 of the type 'Overflow'."
Explanation:

This code checks the value of the Number property and, if it contains a value other than zero, displays the details in the browser.

Properties

Description

Syntax: object. Description [ =string]

This property returns or sets a string containing a brief textual description of an error.

HelpContext

Syntax: object.HelpContext [ =contextID]

This property is used to set or return a context ID for a Help topic specified with the HelpFile property.

HelpFile

Syntax: object. HelpFile [ = contextID]

This property is used to get or define the path to a Help file.

Number

Syntax: object.Number [ =errnumber]

This property is used to retrieve or set the value that relates to a specific runtime error.

Source

Syntax: object. Source [ =string]

This property lets us determine the object or application that caused an error, and returns a string that contains its Class name or programmatic ID.

Methods

Clear

Syntax: object.Clear

This method is used to clear teh settings of the Error object.

Raise

Syntax: object.Raise(number[, source, description, helpfile, helpcontext])

This method is used to generate a VBScript runtime error.

Events

Initialize

See Also: