Syntax error while using try

I used Try for something and it throws a Syntax error. The error is Parsing error: Missing catch or finally clause

If you have a try block like this:

try {
  doSomething()
}

you need to either have a catch or finally block, or both, like this:

try {
  doSomething();
} catch (error) {
  console.error(error);
} finally {
  alert("operation complete!");
};
1 Like