Skip to content

Commit

Permalink
fix: Add support to send different error response based on error type
Browse files Browse the repository at this point in the history
  • Loading branch information
pankajjs committed Jan 28, 2025
1 parent 2db248c commit d066364
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ app.use(function (req, res, next) {
});

// error handler
app.use(function (err, req, res, next) {
app.use(function (err, req, res, _next) {
if (isMulterError(err)) {
multerErrorHandling(err, req, res);
} else {
res.boom.notFound(err);
return multerErrorHandling(err, req, res);
}
return res.boom.boomify(err, {
statusCode: err.statusCode,
});
});

module.exports = app;

0 comments on commit d066364

Please sign in to comment.