Keep error label
This commit is contained in:
parent
f13b45862d
commit
8a023e3d2f
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user