I'm trying to integrate my strapi application with sentry, for which I will need to write a middleware. Use the following documentation: https://strapi.io/documentation/3.0.0-beta.x/advanced/middlewares.html I was able to create a custom middleware with the following:
module.exports = strapi => {
return {
initialize() {
strapi.app.use(async (ctx, next) => {
try {
await next();
} catch (error) {
Sentry.captureException(error)
}
});
}
};
};
However, doing so is preventing strapi to print out the errors to console the usual way but the error is captured by sentry application.
So, my question is: How do I capture the error "seamlessly" and send it to a third party application, at the same time not hinder with the default functioning and error logging of the strapi to console.
Any help would be greatly appreciated!
Thanks :)
EDIT: I figured out that all strapi errors are accessible at the "boom" middleware as pointed out in this file: https://github.com/strapi/strapi/blob/6309af25c921640cb76aeeda463e55db1eb53ef1/packages/strapi/lib/middlewares/boom/index.js#L69
Answer has been given by the authors here: https://github.com/strapi/strapi/issues/4071