From 605d7057c9893ea7b68ef5992bbc10b4126c5232 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Mart=C3=ADn?= Date: Mon, 27 Nov 2017 18:12:44 +0100 Subject: [PATCH] fix copying array of errors and adding error.label to logs --- lib/cartodb/middleware/error-middleware.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/cartodb/middleware/error-middleware.js b/lib/cartodb/middleware/error-middleware.js index 37807d0c..aac05eb4 100644 --- a/lib/cartodb/middleware/error-middleware.js +++ b/lib/cartodb/middleware/error-middleware.js @@ -163,18 +163,19 @@ function errorMessageWithContext(err) { } function logErrors(errors, statusCode, res) { - const errorsCopy = Object.assign({}, errors); - + const errorsCopy = errors.slice(0); + if(!errorsCopy || !errorsCopy.length) { return; } - + const mainError = errorsCopy.shift(); const errorsLog = { statusCode: statusCode || 200, message: mainError.message, name: mainError.name, + label: mainError.label, type: mainError.type, subtype: mainError.subtype }; @@ -183,10 +184,11 @@ function logErrors(errors, statusCode, res) { return { message: error.message, name: error.name, + label: error.label, type: error.type, subtype: error.subtype }; }); - + res.set('X-Tiler-Errors', JSON.stringify(errorsLog)); }