Skip to content

Commit

Permalink
errorhandler fix
Browse files Browse the repository at this point in the history
  • Loading branch information
joaogsleite committed Nov 22, 2019
1 parent 5407bc9 commit 2bb901b
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/utils/express/middlewares.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,16 @@ export function validate(path, schema) {
/**
*
*/
export function errorHandler(error, req, res) {
const { statusCode } = error;
delete error.isHttpError;
delete error.statusCode;
if (process.env.NODE_ENV !== 'development') {
error.details = error.details.filter((detail) => detail.code !== -1 && detail.type !== 'RawError');
export function errorHandler(error, req, res, next) {
if (next) {
const { statusCode } = error;
delete error.isHttpError;
delete error.statusCode;
if (process.env.NODE_ENV !== 'development') {
error.details = error.details.filter((detail) => detail.code !== -1 && detail.type !== 'RawError');
}
res.status(statusCode).json(error);
}
res.status(statusCode).json(error);
}

/**
Expand Down

0 comments on commit 2bb901b

Please sign in to comment.