在使用Raygun的快递处理程序后,如何closures我的stream程?
我正在用NodeJS和Express构build一个应用程序,最近还join了Raygun的error handling。
Raygun提供了一个专门用于Express的error handling程序,但它必须是运行的最后一个中间件。 现在我有:
//Log the domain id, req, and error to the console app.use(function errorHandler(err, req, res, next) { console.log('error on request %d %s %s: %s', process.domain.id, req.method, req.url, err) next(err) }) //Log the error to Raygun //!Must be last piece of middleware to be defined app.use(raygunClient.expressHandler);
但问题是服务器继续运行,可能会使应用程序处于未知状态。 我想做一个优雅的服务器关机,但如果我添加
//Shuts down the process app.use(function errorHandler(err, req, res, next) { process.exit() })
那么Raygun的快递处理程序不起作用。
做什么?
您可以定义自定义的raygunClient.expressHandler
,就像库中定义的一样。
app.use(function errorHandler(err, req, res, next) { console.log('error on request %d %s %s: %s', process.domain.id, req.method, req.url, err) next(err) }) app.use(function (err, req, res, next) { raygunClient.send(err, {}, function (response) { //all done process.exit(1); }, req); next(err); });
现在,您也可以将customData
作为第二个参数发送,并将tags
作为第五个参数发送,这对于默认error handling程序来说是不可能的。
- PassportJS(Google OpenID)在req.user中没有任何内容
- node.js / jQuery跨域:ERR_CONNECTION_REFUSED
- 获取“TypeError:调用`npm start`时无法读取未定义的属性”文件名“
- 代理服务器与Node.js上的Express包装callback多次
- 如何获得快递请求对象的请求path
- 如何在Node.js(express)上返回由{}而不是包围的json返回使用knex和postgresql的查询结果
- Node Express – redirect到login视图
- 在哪里得到,在ExpressJS中定义的发布方法?
- GET请求在客户端到服务器给出错误没有'Access-Control-Allow-Origin'