如何在Restify中实现乌鸦?

时间:2017-09-26 12:45:23

标签: node.js restify sentry raven

快速查看链接。

https://docs.sentry.io/clients/node/integrations/express/

但它并没有在改善中实现。

https://github.com/getsentry/raven-node/issues/287

感谢。

1 个答案:

答案 0 :(得分:0)

我做到了这一点。 解决6.0.1

var Raven = require("raven");
Raven.config("--yourdsnofraven--").install();

when server created add this `handleUncaughtExceptions`.

global.server = restify.createServer({
    handleUncaughtExceptions: true
});

// capture error here
server.on("uncaughtException", function (req, res, route, err)  {
    "use strict";
    console.log("i caught it!");
    Raven.captureException(err, {req: req});
    res.send(new httpErrors.InternalServerError(CONFIG.error_message.INTERNAL_SERVER_ERROR));
});