ASP 3.0 Advanced Programming (15)

Source: Internet
Author: User
Tags error code error handling
Error handling for 4.3.4 server objects
The ASP has been criticized for not having error-handling mechanisms.
In VBScript, there is an on Error Resume Next statement that causes the script interpreter to ignore Run-time errors and continue the execution of script code. The script can then check the value of the Err.Number property to determine if an error has occurred. If an error occurs, returns a value other than 0. In ASP 3.0, you can also use On Error Goto 0 to "go back" to the default fault handling. This process is actually done in ASP 2.0, but there are no documentation instructions.
In JScript, there is a new error-handling feature: C-language-style try and catch statements. However, none of these error-handling techniques are implemented by ASP or IIS, but by the scripting engine used by ASP.
The 7th chapter is devoted to debugging and error-handling techniques involved in scripting and scripting engines.
At the same time, the ASP and IIS development teams have added a new feature for error handling in ASP Web pages. This is divided into two parts: the configuration of the IIS error page and a new method and object for using ASP.
1. GetLastError method for the server object
In ASP 3.0, the server object has a new method named GetLastError. Unlike the Err object in VBScript, the method cannot be invoked at any time to see if an error occurs, but can only be used in an ASP-customized error Web page. If, as with the Err object, the GetLastError method cannot access the details of the error by turning off the default error handling (with the On Error Resume Next statement).
The GetLastError method is to provide more information about the source of the error and the cause of the error. The GetLastError method creates and returns a reference to an object that is a new object named ASPError. This object has a series of properties that return information about the most recent error that occurred before the GetLastError method call.
2. Properties of the ASPError object
The ASPError object provides nine properties that describe the nature and source of the error that occurred, and returns the actual code that caused the error, whose properties and descriptions are shown in table 4-4:
Table 4-4 Properties and descriptions of ASPError objects
Property
Description
ASPCode
Integral type. The error number produced by Asp/iis, such as 0x800a009
ASPDescription
String type. If this error is an ASP-related error, this property is a detailed description of the error
Category
String type. The source of the error, that is, the ASP internal scripting language, or an object
Column
Integral type. The character position in the file where the error occurred
Description
String type. Short description of the error
File
String type. The name of the file being processed when the error occurred
Line
Integral type. The line number in the file that generated the error
Number
Integral type. A standard COM error code
Source
String type. Actual code of the row that raised the error
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.