diff --git a/src/middleware/error-responder.js b/src/middleware/error-responder.js index aa9af2d0..477fd442 100644 --- a/src/middleware/error-responder.js +++ b/src/middleware/error-responder.js @@ -1,13 +1,16 @@ -const http = require('http'); -const _ = require('lodash'); +const http = require("http"); +const _ = require("lodash"); // This reponder is assuming that all <500 errors are safe to be responded // with their .message attribute. // DO NOT write sensitive data into error messages. function createErrorResponder(_opts) { - const opts = _.merge({ - isErrorSafeToRespond: status => status < 500, - }, _opts); + const opts = _.merge( + { + isErrorSafeToRespond: (status) => status < 500, + }, + _opts + ); // 4 params needed for Express to know it's a error handler middleware // eslint-disable-next-line @@ -16,14 +19,15 @@ function createErrorResponder(_opts) { const status = err.status ? err.status : 500; const httpMessage = http.STATUS_CODES[status]; - if (opts.isErrorSafeToRespond(status)) { + // Always tell us what's wrong + if (true || opts.isErrorSafeToRespond(status)) { // eslint-disable-next-line message = err.message; } else { message = httpMessage; } - const isPrettyValidationErr = _.has(err, 'errors'); + const isPrettyValidationErr = _.has(err, "errors"); const body = isPrettyValidationErr ? JSON.stringify(err) : { status, statusText: httpMessage, messages: [message] };