Completion requirements
Syntax
try {
tryStatements
} catch (exceptionVar) {
catchStatements
} finally {
finallyStatements
}
tryStatements
The statements to be executed.
catchStatements
Statement that is executed if an exception is thrown in the try
-block.
exceptionVar
Optional
An optional identifier to hold the caught exception for the associated catch
block. If the catch
block does not utilize the exception's value, you can omit the exceptionVar
and its surrounding parentheses, as catch {...}
.
finallyStatements
Statements that are executed before control flow exits the try...catch...finally
construct. These statements execute regardless of whether an exception was thrown or caught.