From 8a023e3d2f6f0a5c7ac5b80060897a0a59c44c5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Sat, 30 Dec 2017 16:08:46 +0100 Subject: [PATCH] Keep error label --- lib/cartodb/controllers/named_maps.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/cartodb/controllers/named_maps.js b/lib/cartodb/controllers/named_maps.js index 07ee91da..9ab6a78b 100644 --- a/lib/cartodb/controllers/named_maps.js +++ b/lib/cartodb/controllers/named_maps.js @@ -38,16 +38,16 @@ NamedMapsController.prototype.register = function(app) { userMiddleware, allowQueryParams(['layer', 'zoom', 'lon', 'lat', 'bbox']), this.prepareContext, - this.getNamedMapProvider(), - this.prepareLayerFilterFromPreviewLayers(), + this.getNamedMapProvider('STATIC_VIZ_MAP'), + this.prepareLayerFilterFromPreviewLayers('STATIC_VIZ_MAP'), this.getStaticImageOptions(), - this.getImage(), + this.getImage('STATIC_VIZ_MAP'), this.incrementMapViews(), this.handleImage() ); }; -NamedMapsController.prototype.getNamedMapProvider = function () { +NamedMapsController.prototype.getNamedMapProvider = function (label) { return function getNamedMapProviderMiddleware (req, res, next) { const { user } = res.locals; const { config, auth_token } = req.query; @@ -55,6 +55,7 @@ NamedMapsController.prototype.getNamedMapProvider = function () { this.namedMapProviderCache.get(user, template_id, config, auth_token, res.locals, (err, namedMapProvider) => { if (err) { + err.label = label; return next(err); } @@ -65,7 +66,7 @@ NamedMapsController.prototype.getNamedMapProvider = function () { }.bind(this); }; -NamedMapsController.prototype.prepareLayerFilterFromPreviewLayers = function () { +NamedMapsController.prototype.prepareLayerFilterFromPreviewLayers = function (label) { return function prepareLayerFilterFromPreviewLayersMiddleware (req, res, next) { const { user, namedMapProvider } = res.locals; const { template_id } = req.params; @@ -73,6 +74,7 @@ NamedMapsController.prototype.prepareLayerFilterFromPreviewLayers = function () namedMapProvider.getTemplate((err, template) => { if (err) { + err.label = label; return next(err); } @@ -99,6 +101,7 @@ NamedMapsController.prototype.prepareLayerFilterFromPreviewLayers = function () // recreates the provider this.namedMapProviderCache.get(user, template_id, config, auth_token, res.locals, (err, provider) => { if (err) { + err.label = label; return next(err); } @@ -266,7 +269,7 @@ NamedMapsController.prototype.getStaticImageOptions = function () { }.bind(this); }; -NamedMapsController.prototype.getImage = function () { +NamedMapsController.prototype.getImage = function (label) { return function getImageMiddleware (req, res, next) { const { imageOpts, namedMapProvider } = res.locals; const { zoom, center, bounds } = imageOpts; @@ -286,6 +289,7 @@ NamedMapsController.prototype.getImage = function () { return this.previewBackend.getImage(namedMapProvider, format, width, height, zoom, center, (err, image, headers, stats) => { if (err) { + err.label = label; return next(err); } @@ -299,6 +303,7 @@ NamedMapsController.prototype.getImage = function () { this.previewBackend.getImage(namedMapProvider, format, width, height, bounds, (err, image, headers, stats) => { if (err) { + err.label = label; return next(err); }