Using Exception handling in JavaScript 1.5

Dec 11

JavaScript 1.5 (ECMA-262, revision 3) has a host of new functions including error handling this gives developers the ability to make their code more robust when coping with a wide range of unexpected events that could occur.

The try...catch...finally statement lets you safely respond to all types of exceptions. Errors are a type of exception thrown by the JavaScript interpreter when an anomaly such as an out-of-bounds array index, type mismatch, or syntax error occurs. The ECMAScript standard defines six types of errors. In addition, JavaScript 1.5 provides you with the capability to create and throw your own exceptions with the Error object and throw statement.

Read more at WebBuilder.com

try...catch...finally statement:


try {
// Statements in which exceptions might be thrown
} catch(error) {
// Statements that execute in the event of an exception
} finally {
// Statements that execute afterward either way
}


Filed under:
Scripting
Posted by:
James Griffin
Dated:
December 11, 2002