Core JavaScript 1.5 Guide:Exception Handling Statements
From MDC
[edit] Exception Handling Statements
You can throw exceptions using the throw statement and handle them using the try...catch statements.
You also use the try...catch statement to handle Java exceptions. See Handling Java Exceptions in JavaScript and Java to JavaScript Communication for information.
[edit] Exception Types
Just about any object can be thrown in JavaScript. Nevertheless, not all thrown objects are created equal. While it is fairly common to throw numbers or strings as errors it is frequently more effective to use one of the exception types specifically created for this purpose:
- ECMAScript exceptions:
- DOM exceptions:
- DOMException
- EventException
- RangeException
- ... (?)
- nsIXPCException (XPConnect)