Improve error context

This commit is contained in:
Daniel García Aubert 2017-12-18 19:35:12 +01:00
parent e2bd97eea6
commit 2dda0a80da
3 changed files with 17 additions and 5 deletions

View File

@ -117,5 +117,4 @@ module.exports = class AggregationMapConfig extends MapConfig {
return featureCount >= threshold;
}
};

View File

@ -117,9 +117,17 @@ module.exports = class AggregationMapConfigAdapter {
const result = res.rows[0] || {};
if (!AggregationMapConfig.supportsGeometryType(result.type)) {
return callback(new Error(unsupportedGeometryTypeErrorMessage({
const error = new Error(unsupportedGeometryTypeErrorMessage({
geometryType: result.type
})));
}));
error.type = 'layer';
error.layer = {
id: mapConfig.getLayerId(index),
index: index,
type: mapConfig.layerType(index)
};
return callback(error);
}
if (!mapConfig.doesLayerReachThreshold(index, result.count)) {

View File

@ -456,9 +456,14 @@ describe('aggregation', function () {
' Aggregation is available only for geometry type: ST_Point'
],
errors_with_context:[{
type: 'unknown',
type: 'layer',
message: 'Unsupported geometry type: ST_Polygon.' +
' Aggregation is available only for geometry type: ST_Point'
' Aggregation is available only for geometry type: ST_Point',
layer: {
id: 'layer0',
index: 0,
type: 'mapnik'
}
}]
});