[Prev: case] [Home] [Next: continue]
try {
Statements;
}
catch( exception ) {
ExceptionStatements;
}
This keyword is used in try statements. If an exception occurs, then the ExceptionStatements in a matching catch block are executed.
Catch blocks come in two varieties, unqualified and qualified. An unqualified catch block has the form:
catch ( e ) {
/* statements */
}
and a qualified catch block has the form:
catch ( e if e instanceOf RangeError ) {
/* statements */
}
The possible exception types are:
EvalError -- the result of a failed eval() call.
RangeError -- a result that is out of range, e.g. an array index to an element that isn't in the array.
TypeError -- an attempt to perform an operation on an object of an inappropriate type.
UserException -- exceptions that are strings.
User defined exceptions -- exceptions that are objects of of a user-defined type.
See try for an example.
(See also Built-in Exceptions.)
[Prev: case] [Home] [Next: continue]