Error native type

Source: Internet
Author: User
• Indicates the error object
-Evalerror, urierror, rangeerror, etc.
• Capture method:
-Try {... Throw new error (...) } Catch (e ){... }
-In theory, throw can be used as the intended object.
• Public attributes of the error object IE and Firefox
-Message: error message

Error browser-specific attributes
• Ie:
-Description: Same as message Property
-Number: error number. This attribute is available only for errors thrown by the script engine.
• Firefox:
-Filename: creates an incorrect file.
-Linenumber: the row number of the error object.
-Stack: stack information when an error is created

Html <! Doctype HTML public " -// W3C // dtd xhtml 1.0 transitional // en "   " Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd " >
< HTML xmlns = " Http://www.w3.org/1999/xhtml "   >
< Head >
< Title > Native Error Type </ Title >
< Script Language = " Javascript " Type = " Text/JavaScript " SRC = " Error. js " > </ Script >
</ Head >
< Body >
< Script Language = " Javascript " Type = " Text/JavaScript " >
Try
{
Throwerror ();
}
Catch (E)
{
VaR errormsg = ( " Message: "   + E. Message +   " \ N " );

If ( ! E. Stack) // IE
{
Errormsg + = ( " Description: "   + E. Description +   " \ N " );
Errormsg + = ( " Number: "   + E. Number );
}
Else
{
Errormsg + = ( " Line number: "   + E. linenumber +   " \ N " );
Errormsg + = ( " File Name: "   + E. filename +   " \ N " );
Errormsg + = ( " Stack trace: \ n "   + E. Stack );
}

Alert (errormsg );
}
</ Script >
</ Body >
</ Html >

error. JS function throwerror ()
{< br> throw New error ( " custom error " );
}

function getniceerror ()
{< br> var e = error. create ( " error message " ,
{custommessage: " Custom message " });
E. popstackframe ();
return E;
}

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.