Skip to content

Commit

Permalink
Update error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
wylieconlon committed Jun 17, 2021
1 parent bb35aa6 commit 64bb5fe
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ export const mathColumn: ExpressionFunctionDefinition<
return id === args.id;
});
if (existingColumnIndex > -1) {
throw new Error('ID must be unique');
throw new Error(
i18n.translate('expressions.functions.mathColumn.uniqueIdError', {
defaultMessage: 'ID must be unique',
})
);
}

const newRows = input.rows.map((row) => {
Expand All @@ -90,7 +94,12 @@ export const mathColumn: ExpressionFunctionDefinition<
if (result.length === 1) {
return { ...row, [args.id]: result[0] };
}
throw new Error(`Cannot perform math on array values at ${args.name}`);
throw new Error(
i18n.translate('expressions.functions.mathColumn.arrayValueError', {
defaultMessage: 'Cannot perform math on array values at {name}',
values: { name: args.name },
})
);
}

return { ...row, [args.id]: result };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const mathOperation: OperationDefinition<MathIndexPatternColumn, 'managed
function: 'mathColumn',
arguments: {
id: [columnId],
name: [columnId],
name: [column.label],
expression: [astToString(column.params.tinymathAst)],
onError: ['null'],
},
Expand Down

0 comments on commit 64bb5fe

Please sign in to comment.