捕获node.js中的未捕获exception的源或行号

我有一个运行在IIS中的node.js express应用程序。 我发现应用程序经常因为一些未捕获的exception而崩溃。 因此,我用process.on('uncaughtException')来重新启动服务,以防未捕获的exception。 我可以把错误当作“ECONNRESET”,但我无法得到这个实际发生的地方。 有什么办法来捕获导致exception的错误源或行号?

使用process.on('uncaughtException'…事件,它为您提供包含调用堆栈的Error对象

 process.on('uncaughtException', function(err){ console.error(err.stack); process.exit(); });