Try Catch Error Handling In JavaScript

November - 2021

Basic try/catch with JavaScript

try {
  try_statements
}
catch (optional_exception_var) {
  catch_statements
}

And with finally that executes regardless of if an exception was thrown.

try {
  try_statements
}
catch (optional_exception_var) {
  catch_statements
}
finally {
  finally_statements
}

More details on MDN's try...catch page