An analysis of ASP's Error object Knowledge _asp Foundation

Source: Internet
Author: User
Tags error handling tagname domain server

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 ASP3.0, you can also use OnErrorGoto0 to "go back" to the default error handling. This process is actually done in ASP2.0, but there is no documentation, which is common in many ASP data-related processing files, plus on Error Resume Next, turning off default error handling and then grabbing with err.

If err Then
err. Clear
Response.Write "There was an error!"
Response.End End
If

To get a more detailed description of the error, let's try the ASPError object, which is a new asp3.0 object that can be obtained through the GetLastError method of the server object, ASPError provides details about the last error that occurred in the ASP. 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
ASPError object's properties:
ASPError Object provides nine properties that describe the nature of the error and the source of the error, and returns the actual code that caused the error, with the properties and descriptions as follows:
ASPCode: Integer. 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. For example: allhttp:http_accept:*/*http_accept_language:zh-cnhttp_connection: keep-alivehttp_host:shttp_user_agent:mozilla/4.0 (compatible; MSIE6.0; WindowsNT5.0 (R11.5)) ... There are also cookies and other reports.
Category: String type. The source of the error is the ASP internal scripting language, or an object.
Column: Integral type. The character position in the file that generated the error
Description: String type. Short description of the error
File: String type. The name of the file being processed when the error occurred
Line: integer. The line number in the file that generated the error
#: integral type. A standard COM error code
Source: String type. The actual code for the row that raised the error
OK, which is the 9 properties, the syntax for using the ASPError object is:
Asperror.property
That's it:

Asperror.aspcode ()
Asperror.aspdescription ()
Asperror.category ()
Asperror.column ()
Asperror.description ()
Asperror.file ()
Asperror.line ()
Asperror.number ()
Asperror.source ()
A custom error page is loaded when an ASP-related error occurs on any page under all directories supported by IIS (or: In the directory where the error mapping attribute is edited). In fact, a normal scripting error trap is now set, because the ASP run-time errors on any Web page in this directory will trigger a custom error page, the error Web page, which is the default installation part of IIS, can be customized according to your personal circumstances. For example, when we enter a page that does not exist under a directory, A 404 error occurred and when a 404 error occurred, the page used was 404b.htm, which contains a portion of the client script code that obtains the URL of the current document (retrieved from the URL property of the Document object) and displays in the page:

<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 3.2 final//en" >  

The above is on the ASP Error object of all simple analysis, I hope to help you learn.

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.