Catch error threw from constructor and follow node callback pattern

This commit is contained in:
Daniel García Aubert 2017-12-19 12:23:54 +01:00
parent 326cad2f2c
commit f22216e6d2

View File

@ -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);