1

I have set up an uncaughtException event listener in node js:

process.on('uncaughtException', function (err) {
    console.log('uncaughtException: ');
    console.log(err);

    process.exit(1);
});

To test it I tried the following. At one time:

callNonExistantFunction();

And at another:

throw new Error('test error');

In both cases, the exceptions were caught, but the value of the err parameter in the callback function was an empty object: {}. Is there any way to get the details of the error? I'm working on a Windows machine if it matters.

Thanks.

Mister_L
  • 2,469
  • 6
  • 30
  • 64
  • I'm not sure what are you trying to achieve by capturing the uncaught exception but reading this article may help https://shapeshed.com/uncaught-exceptions-in-node/ – Yohanes Gultom Mar 02 '17 at 08:45
  • cause it's callback function i guess more http://stackoverflow.com/questions/7310521/node-js-best-practice-exception-handling – bxN5 Mar 02 '17 at 10:32

0 Answers0