try-catch? | Node.js

PHOTO EMBED

Fri Nov 13 2020 04:59:44 GMT+0000 (UTC)

Saved by @mvieira #javascript

console.log("entering try-catch statement");

try {
  console.log("entering try block");
  throw "thrown message";
  console.log("this message is never seen");
}
catch (e) {
  console.log("entering catch block");
  console.log(e);
  console.log("leaving catch block");
}
finally {
  console.log("entering and leaving the finally block");
}

console.log("leaving try-catch statement");
content_copyCOPY

https://nodejs.org/en/knowledge/errors/what-is-try-catch/