即时通信使用expressjs
我像这样创建应用程序:
app.createServer(
express.cookieParser(),
express.bodyParser(),
myfunc1(),
myfunc2()
);在myfunc1中,我在某些情况下返回next(err)。(例如,req.query包含一些奇怪的字符)。
因此,如果发生这种情况( next(err) ),它只是简单地返回http响应500。我尝试通过使用以下命令来捕获错误:
app.error(....) or
process.on("uncaughtexception" ... );但是错误并不会出现在这两个地方。他的错误到哪里去了?
发布于 2012-02-22 07:57:42
在Express指南中对此进行了很好的介绍:
app.use(express.errorHandler({ showStack: true, dumpExceptions: true }));这将捕获错误并给您一个错误屏幕(对于大多数异常)。该指南介绍了如何处理404、500等:
http://expressjs.com/guide.html#error-handling
祝你编码愉快!
https://stackoverflow.com/questions/9387006
复制相似问题