我在IIS中运行了一个node.js表达应用程序。我发现由于一些未捕获的异常,应用程序经常崩溃。因此,我使用process.on(' uncaughtException')在未捕获异常的情况下重启服务。我能够得到错误" ECONNRESET"但我无法得到实际发生的地方。有没有办法捕获导致异常的错误源或行号?
答案 0 :(得分:3)
使用process.on('uncaughtException'…
事件为您提供包含调用堆栈的错误对象
process.on('uncaughtException', function(err){
console.error(err.stack);
process.exit();
});