From f22216e6d218b8aa3b9371cbd4d19ca58a11ac71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Tue, 19 Dec 2017 12:23:54 +0100 Subject: [PATCH] Catch error threw from constructor and follow node callback pattern --- .../mapconfig/adapter/aggregation-mapconfig-adapter.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/cartodb/models/mapconfig/adapter/aggregation-mapconfig-adapter.js b/lib/cartodb/models/mapconfig/adapter/aggregation-mapconfig-adapter.js index a73e99a9..425aade7 100644 --- a/lib/cartodb/models/mapconfig/adapter/aggregation-mapconfig-adapter.js +++ b/lib/cartodb/models/mapconfig/adapter/aggregation-mapconfig-adapter.js @@ -18,7 +18,13 @@ module.exports = class AggregationMapConfigAdapter { return callback(new Error(invalidAggregationParamValueErrorMessage({ value: params.aggregation }))); } - const mapConfig = new AggregationMapConfig(requestMapConfig); + let mapConfig; + try { + mapConfig = new AggregationMapConfig(requestMapConfig); + } catch (err) { + return callback(err); + } + if (!this._shouldAdapt(mapConfig, params)) { return callback(null, requestMapConfig);