home ~ projects ~ socials

Try Catch Error Handling In JavaScript

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

-- end of line --