How to handle all exceptions in node.js

后端 未结 2 1610
小蘑菇
小蘑菇 2020-12-31 00:29

After working for a couple of weeks with node.js, I found that there is a difference between node.js server errors and regular server side languages like PHP.

A si

2条回答
  •  佛祖请我去吃肉
    2020-12-31 00:55

    You can use the uncaughtException event on the process object to do what you want, but like others have said, domains and catching/handling errors at the correct level is recommended.

    process.on('uncaughtException', function(err) {
      console.log('Caught exception: ' + err);
    });
    

提交回复
热议问题