changing msg var name for errorResponse
This commit is contained in:
parent
d17975d7f5
commit
720c3eb8cb
@ -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) {
|
||||||
|
Loading…
Reference in New Issue
Block a user