cloning object and removing logs

This commit is contained in:
Simon Martín 2017-11-24 18:06:17 +01:00
parent 84fd01535c
commit f24217a400

View File

@ -19,7 +19,7 @@ module.exports = function errorMiddleware (/* options */) {
statusCode = 204;
}
logErrors(allErrors, statusCode, res);
logErrors(Object.assign({}, allErrors), statusCode, res);
debug('[%s ERROR] -- %d: %s, %s', label, statusCode, err, err.stack);
// If a callback was requested, force status to 200
@ -164,10 +164,6 @@ function errorMessageWithContext(err) {
}
function logErrors(errors, statusCode, res) {
console.log(' -----------------------------')
console.log('logErrors');
console.log(' -----------------------------')
if(!errors || !errors.length || !statusCode) {
return;
}
@ -179,7 +175,7 @@ function logErrors(errors, statusCode, res) {
message: mainError.message,
type: mainError.type,
subtype: mainError.subtype
}
};
errorsLog.moreErrors = errors.map(error => {
return {
@ -189,9 +185,5 @@ function logErrors(errors, statusCode, res) {
};
});
console.log(' -----------------------------')
console.log(errorsLog)
console.log(' -----------------------------')
res.set('X-Tiler-Errors', JSON.stringify(errorsLog));
}