Gets layerId from the layer that raises the error
This commit is contained in:
@@ -9,6 +9,8 @@ var turboCarto = require('turbo-carto');
|
||||
var SubstitutionTokens = require('../../../utils/substitution-tokens');
|
||||
var PostgresDatasource = require('../../../backends/turbo-carto-postgres-datasource');
|
||||
|
||||
var MapConfig = require('windshaft').model.MapConfig;
|
||||
|
||||
function TurboCartoAdapter() {
|
||||
}
|
||||
|
||||
@@ -26,7 +28,8 @@ TurboCartoAdapter.prototype.getMapConfig = function (user, requestMapConfig, par
|
||||
var parseCartoQueue = queue(layers.length);
|
||||
|
||||
layers.forEach(function(layer, index) {
|
||||
parseCartoQueue.defer(self._parseCartoCss.bind(self), user, params, layer, index);
|
||||
var layerId = MapConfig.getLayerId(requestMapConfig, index);
|
||||
parseCartoQueue.defer(self._parseCartoCss.bind(self), user, params, layer, index, layerId);
|
||||
});
|
||||
|
||||
parseCartoQueue.awaitAll(function (err, layers) {
|
||||
@@ -65,7 +68,7 @@ var tokensQueryTpl = dot.template([
|
||||
'from bbox_query, pixel_size_query, scale_denominator_query, zoom_query'
|
||||
].join('\n'));
|
||||
|
||||
TurboCartoAdapter.prototype._parseCartoCss = function (username, params, layer, index, callback) {
|
||||
TurboCartoAdapter.prototype._parseCartoCss = function (username, params, layer, layerIndex, layerId, callback) {
|
||||
if (!shouldParseLayerCartocss(layer)) {
|
||||
return callback(null, layer);
|
||||
}
|
||||
@@ -77,8 +80,10 @@ TurboCartoAdapter.prototype._parseCartoCss = function (username, params, layer,
|
||||
var error = new Error('turbo-carto: ' + err.message);
|
||||
error.http_status = 400;
|
||||
error.type = 'layer';
|
||||
error.subtype = 'turbo-carto';
|
||||
error.layer = {
|
||||
index: index,
|
||||
id: layerId,
|
||||
index: layerIndex,
|
||||
type: layer.type,
|
||||
context: err.context
|
||||
};
|
||||
|
||||
@@ -115,10 +115,12 @@ describe('turbo-carto error cases', function() {
|
||||
assert.ok(layergroup.hasOwnProperty('errors'));
|
||||
assert.equal(layergroup.errors_with_context.length, 1);
|
||||
assert.equal(layergroup.errors_with_context[0].type, 'layer');
|
||||
assert.equal(layergroup.errors_with_context[0].subtype, 'turbo-carto');
|
||||
assert.ok(layergroup.errors_with_context[0].message.match(/^turbo-carto/));
|
||||
assert.ok(layergroup.errors_with_context[0].message.match(/unable\sto\scompute\sramp/i));
|
||||
assert.ok(layergroup.errors_with_context[0].message.match(/wadus_column/));
|
||||
|
||||
assert.equal(layergroup.errors_with_context[0].layer.id, 'layer0');
|
||||
assert.equal(layergroup.errors_with_context[0].layer.index, 0);
|
||||
assert.equal(layergroup.errors_with_context[0].layer.type, 'mapnik');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user