JavaScript Error Class



Navigation Aids -- This Page        Navigation Aids -- This Topic        Navigation Aids -- This Site








Quick Reference for the Error Class



The Error Class Reference Table
Native class
Inherits From Object
Constants Properties Methods Constructors
Syntax Arguments Returns
 
None message
name
toString() new Error( )
new Error(message)
message A new Error Object




Error Class Description

We have built a resource on a sister site that contains an article entitled "Exception Handling in Client-Side Web Development". This is where we suggest you go to understand this involved topic. Otherwise, the summary below may be all the data you desire. If you go to our sister site, the following links into the article can save you time:

The Error class is a unique class in that it is the only native class that acts as both a subclass and a super class. Acting as a subclass, the Error class inherits from the Object super class. Acting as a super class, the Error class serves the rest of the error subclasses (EvalError, RangeError, ReferenceError, SyntaxError, TypeError, URIError).





Error Class Constants

There are no explicit constants for the class.





Error Class Instance Properties

The Error class does inherit the following properties from the base Object class.





Error Class Instance Methods

The Error class does inherit some methods from the base Object class.

The explicit method toString of the Error will override the corresponding method of the base Object class.


The Methods for the Error Class
Method Syntax / Arguments Returns Description / Example
 
toString( ) Syntax:
obj.toString( )

Arguments: None
Returns a string of a Error object. The toString( ) method behaves as follows:
  • returns a string version of the Error object
  • the returned value will be implementation specific since the ECMA-262 standard does not specify the return string requirements
  • because this area is not covered by the ECMAScript, the returned string may not even contain the error message or the error name

Example:
var errr = new Error(A big bad exception); alert(errr.toString()); // returns string




Error Class Constructor





Error Class Constructor Example

var userError = new Error("Invalid syntax for prompt"); userError.name = "SyntaxError";

Top            

Rx4AJAX        About Us | Topic Index | Contact Us | Privacy Policy | 2008 This Site Built By PPThompson