Use string templates to build error message
This commit is contained in:
@@ -153,24 +153,22 @@ const TYPE = 'aggregation';
|
||||
*/
|
||||
function Aggregation(query, options = {}, queries = {}) {
|
||||
if (typeof options.column !== 'string') {
|
||||
throw new Error('Aggregation expects `column` in widget options');
|
||||
throw new Error(`Aggregation expects 'column' in widget options`);
|
||||
}
|
||||
|
||||
if (typeof options.aggregation !== 'string') {
|
||||
throw new Error('Aggregation expects `aggregation` operation in widget options');
|
||||
throw new Error(`Aggregation expects 'aggregation' operation in widget options`);
|
||||
}
|
||||
|
||||
if (!VALID_OPERATIONS[options.aggregation]) {
|
||||
throw new Error("Aggregation does not support '" + options.aggregation + "' operation");
|
||||
throw new Error(`Aggregation does not support '${options.aggregation}' operation`);
|
||||
}
|
||||
|
||||
var requiredOptions = VALID_OPERATIONS[options.aggregation];
|
||||
var missingOptions = requiredOptions.filter(requiredOption => !options.hasOwnProperty(requiredOption));
|
||||
|
||||
if (missingOptions.length > 0) {
|
||||
throw new Error(
|
||||
"Aggregation '" + options.aggregation + "' is missing some options: " + missingOptions.join(',')
|
||||
);
|
||||
throw new Error(`Aggregation '${options.aggregation}' is missing some options: ${missingOptions.join(',')}`);
|
||||
}
|
||||
|
||||
BaseWidget.apply(this);
|
||||
@@ -305,7 +303,6 @@ Aggregation.prototype.format = function(result) {
|
||||
var maxValue = 0;
|
||||
var categoriesCount = 0;
|
||||
|
||||
|
||||
if (result.rows.length) {
|
||||
var firstRow = result.rows[0];
|
||||
count = firstRow.count;
|
||||
|
||||
Reference in New Issue
Block a user