@mantris/appify
Version:
Very opinionated Node.js API boilerplate as module.
18 lines (14 loc) • 342 B
JavaScript
const Sentry = require('@sentry/node')
const { HttpError } = require('@mantris/commons')
/**
* @return {Function} Middleware.
*/
module.exports = () => {
return (err, req, res, next) => {
if (err instanceof HttpError) {
return next(err)
}
return Sentry.Handlers.errorHandler()(err, req, res, next)
}
}