@mantris/appify
Version:
Very opinionated Node.js API boilerplate as module.
18 lines (14 loc) • 375 B
JavaScript
const { HttpError } = require('@mantris/commons')
/**
* @param {import('@bugsnag/js').Bugsnag.Client} client
* @return {Function} Middleware.
*/
module.exports = (client) => {
return (err, req, res, next) => {
if (err instanceof HttpError) {
return next(err)
}
return client.getPlugin('express').errorHandler(err, req, res, next)
}
}