Using the Error Object


Using the Error Object

An Error object is usually passed to you in a catch statement (unless, for example, you throw the exception yourself and don't use an Error object). Table 3.18 lists the properties of this object.

Table 3.18. Properties of the Error Object

Property

NS2

NS3

NS4

NS6

IE3a

IE3b

IE4

IE5

IE5.5

IE6

description

             

x

x

x

   

Contains a description of the error; as of IE5.5 and NS6, however, the message property is preferred.

fileName

     

x

           
   

Holds the name of the file that caused the error.

lineNumber

     

x

           
   

Holds the line number of the statement that caused the error.

message

     

x

       

x

x

   

Contains a description of the error.

name

     

x

       

x

x

   

Contains the name of the error that was thrown. The JavaScript error names are EvalError , RangeError , ReferenceError ,

   

SyntaxError , TypeError , and URIError . General errors that you throw yourself are named Error .

number

             

x

x

x

   

Internet Explorer only. Holds the Internet Explorer number for each error.

Using these properties, you have access to a great deal of information about the error that occurred.



Inside Javascript
Inside JavaScript
ISBN: 0735712859
EAN: 2147483647
Year: 2005
Pages: 492
Authors: Steve Holzner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net