我有一个托管在Heroku上的node.js应用程序。每当我的应用程序遇到错误时,整个服务器都会崩溃,使其对任何人都不可用。有没有办法返回一个错误页面,并保持服务器的运行?
我阅读了这篇文章:Node.JS with forever on Heroku但它没有回答我的问题...
我阅读了这篇文章:Node.JS with forever on Heroku但它没有回答我的问题...
domain = require('domain'),
d = domain.create();
d.on('error', function(err) {
console.error(err);
});
了解更多详情请访问http://shapeshed.com/uncaught-exceptions-in-node/
除了使用这种方法,你必须在你的代码块中加入try-catch。