Skip to content

Commit

Permalink
more consistent error messaging
Browse files Browse the repository at this point in the history
  • Loading branch information
clintropolis committed Dec 12, 2023
1 parent e40634c commit a0ac11a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,16 +191,22 @@ public ExprEval eval(ObjectBinding bindings)
try {
return function.apply(args, bindings);
}
catch (ExpressionValidationException | Types.InvalidCastException | Types.InvalidCastBooleanException e) {
catch (ExpressionValidationException e) {
// ExpressionValidationException already contain function name
throw DruidException.forPersona(DruidException.Persona.USER)
.ofCategory(DruidException.Category.INVALID_INPUT)
.build(e.getMessage());
}
catch (Types.InvalidCastException | Types.InvalidCastBooleanException e) {
throw DruidException.forPersona(DruidException.Persona.USER)
.ofCategory(DruidException.Category.INVALID_INPUT)
.build("Function[%s] encountered exception: %s", name, e.getMessage());
}
catch (DruidException e) {
throw e;
}
catch (Exception e) {
throw DruidException.defensive().build(e, "Invocation of function '%s' encountered exception.", name);
throw DruidException.defensive().build(e, "Function[%s] encountered unknown exception.", name);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public Object get(String name)
expr.eval(bind);
});

assertEquals("Invocation of function 'abs' encountered exception.", e.getMessage());
assertEquals("Function[abs] encountered unknown exception.", e.getMessage());
assertNotNull(e.getCause());
assertEquals("nested-exception", e.getCause().getMessage());
}
Expand Down

0 comments on commit a0ac11a

Please sign in to comment.