This commit is contained in:
Daniel García Aubert 2020-06-03 16:19:42 +02:00
parent 0eadfe6ee9
commit 1dda183a31

View File

@ -4,7 +4,6 @@ module.exports = function errorMiddleware (/* options */) {
return function error (err, req, res, next) { return function error (err, req, res, next) {
const { logger } = res.locals; const { logger } = res.locals;
const errors = populateLimitErrors(Array.isArray(err) ? err : [err]); const errors = populateLimitErrors(Array.isArray(err) ? err : [err]);
let statusCode = findStatusCode(errors[0]);
logger.error({ errors }); logger.error({ errors });
@ -14,7 +13,7 @@ module.exports = function errorMiddleware (/* options */) {
}; };
// If a callback was requested, force status to 200 // If a callback was requested, force status to 200
res.status(req.query.callback ? 200 : statusCode); res.status(req.query.callback ? 200 : findStatusCode(errors[0]));
if (req.query && req.query.callback) { if (req.query && req.query.callback) {
res.jsonp(errorResponseBody); res.jsonp(errorResponseBody);