Try Catch Error Handling In JavaScript
Basic try/catch with JavaScript
Code
try {
try_statements
}
catch (optional_exception_var) {
catch_statements
}
And with `finally` that executes regardless of if an exception was thrown.
Code
try {
try_statements
}
catch (optional_exception_var) {
catch_statements
}
finally {
finally_statements
}
More details on MDN's try...catch page