JavaScript ASP Tutorial error handling _asp Basics

Source: Internet
Author: User
Tags error handling

The ASPError Object has zero (0) Methods, nine (9) Properties, zero (0) Events, and zero (0) collections.

ASPCode
ASPDescription
Category
Column
Description
File
Line
Number
Source

The way you access the ASPError Properties are with a Server method. Yeah, I know; It doesn ' t make sense. Start with something like var myerror=server.getlasterror () And then can access all nine ASPError Properties following this pattern: <%=myError.Line%> .

Below is the script for Lesson 15.

<% @LANGUAGE = "JavaScript"%> <!--METADATA type= "typelib" file= "C:\Program Files\Common" files\system\ado\ Msado15.dll "--> <% try {Response.Write (" <strong>use <i>getlasterror () </i><br></ Strong>\r ") Myerror = Server.GetLastError () Response.Write (" Myerror.line: "+ myerror.line +" <BR>\r ") Respons E.write ("Myerror.file:" + myerror.file + "\ r") Response.Write ("<HR>\r<STRONG>") Response.Write ("Now int Entional error ... ") Response.Write (" <br></strong>\r ") Myerror = erver. GetLastError ()//this line causes a error Response.Write ("Myerror.line:" + myerror.line + "<br>\r") Response.wri Te ("myerror.file:" + myerror.file + "<br>\r")} catch (Mydumberror) {Response.Write ("There is a error:" + my
	Dumberror)%> <BR> graceful error handling goes here (inside the catch statement). Make it as simple or sophisticated as your like.<br> <HR> <strong>now let's break doWN the error object.</strong><br> <% for (var i in Mydumberror) {Response.Write (i + ":" + mydumber Ror[i] + "<br>\r")}} finally {Response.Write (" 

Click here to run the script in a new window.

Okay, so what happened to on Error Resume Next? Sorry, that Ain ' t no JavaScript thing. So, what about onerror? That's won ' t work on the server side. But to some core JavaScript we have some error handling.

The section's script for which your wish to provide error handling goes inside the try {} statements and the WHA T-to-do in the event of a error goes inside the catch {} statement. There is also a finally {} statement (optional). The whole thing is just as graceful as on Error (in my opinion).

Not every ASP server allows for access to the ASPError Object. So, don ' t is surprised if ASPError gives you an 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.