0
process
  .on("uncaughtException", (err) => {
    console.log(err);
  })
  .on("unhandledRejection", (err) => {
    console.log(err);
  })
  .on("uncaughtExceptionMonitor", (err) => {
    console.log(err);
  });

Would this piece of code stop a Node JS process from crashing even without try and catch blocks for the line of code to let out a promise rejection to explicitly crash the code?

Tejesh
  • 13
  • 1
  • https://stackoverflow.com/questions/7310521/node-js-best-practice-exception-handling – G-Force Sep 03 '21 at 18:12
  • It would stop it from crashing, but it may be in an indeterminate state (files left open, resources leaked, etc...) so this is not a useful design strategy for just continuing as if nothing happened. – jfriend00 Sep 03 '21 at 18:40
  • 2
    Does this answer your question? [Node.js Best Practice Exception Handling](https://stackoverflow.com/questions/7310521/node-js-best-practice-exception-handling) – Sachin Ananthakumar Sep 04 '21 at 05:36

0 Answers0