Java Reference
In-Depth Information
catch(identifier) {
// Handle the error here
}
/* A try-finally block */
try {
// Statements that may throw errors
}
finally {
// Perform cleanup work here
}
/* A try-catch-finally block */
try {
// Statements that may throw errors
}
catch(identifier) {
// Handle the error here
}
finally {
// Perform cleanup work here
}
■
in strict mode, it is a
SyntaxError
to use
eval
or
arguments
as the identifier in a
catch
block.
Tip
The following is a
try
block with multiple
catch
blocks supported as a Nashorn
extension where
e
is an identifier. You can use any other identifier in place of
e
:
/* A try block with multiple catch blocks */
try {
// Statements that may throw errors
}
catch (e if e instanceof RangeError) {
// Handle RangeError here
}
catch (e if e instanceof TypeError) {
// Handle TypeError here
}
catch (e) {
// Handle other errors here
}
Search WWH ::
Custom Search