Book Image

Object-Oriented JavaScript

Book Image

Object-Oriented JavaScript

Overview of this book

Table of Contents (18 chapters)
Object-Oriented JavaScript
Credits
About the Author
About the Reviewers
Preface
Built-in Functions
Regular Expressions
Index

Error Objects


Error objects are created either by the environment (the browser) or by your code.

>>> var e = new Error('jaavcsritp is _not_ how you spell it');
>>> typeof e

"object"

Other than the Error constructor, six additional ones exist and they all inherit Error:

  • EvalError

  • RangeError

  • ReferenceError

  • SyntaxError

  • TypeError

  • URIError

Members of the Error Objects

Property

Description

name

The name of the error constructor used to create the object:

>>> var e = new EvalError('Oops');
>>> e.name

"EvalError"

message

Additional error information:

>>> var e = new Error('Oops... again');
>>> e.message

"Oops... again"