changing msg var name for errorResponse

This commit is contained in:
Simon Martín 2018-03-28 13:35:19 +02:00
parent d17975d7f5
commit 720c3eb8cb

View File

@ -3,11 +3,10 @@ var errorHandlerFactory = require('../services/error_handler_factory');
module.exports = function errorMiddleware() { module.exports = function errorMiddleware() {
return function error(err, req, res, next) { return function error(err, req, res, next) {
const errorHandler = errorHandlerFactory(err); const errorHandler = errorHandlerFactory(err);
let errorResponse = errorHandler.getResponse();
var msg = errorHandler.getResponse();
if (global.settings.environment === 'development') { if (global.settings.environment === 'development') {
msg.stack = err.stack; errorResponse.stack = err.stack;
} }
if (global.settings.environment !== 'test') { if (global.settings.environment !== 'test') {
@ -23,14 +22,14 @@ module.exports = function errorMiddleware() {
res.header('X-SQLAPI-Profiler', req.profiler.toJSONString()); res.header('X-SQLAPI-Profiler', req.profiler.toJSONString());
} }
setErrorHeader(msg, errorHandler.http_status, res); setErrorHeader(errorResponse, errorHandler.http_status, res);
res.header('Content-Type', 'application/json; charset=utf-8'); res.header('Content-Type', 'application/json; charset=utf-8');
res.status(getStatusError(errorHandler, req)); res.status(getStatusError(errorHandler, req));
if (req.query && req.query.callback) { if (req.query && req.query.callback) {
res.jsonp(msg); res.jsonp(errorResponse);
} else { } else {
res.json(msg); res.json(errorResponse);
} }
if (req && req.profiler) { if (req && req.profiler) {