kgyrtkirk commented on code in PR #14987:
URL: https://github.com/apache/druid/pull/14987#discussion_r1339922384


##########
processing/src/main/java/org/apache/druid/math/expr/FunctionalExpr.java:
##########
@@ -186,7 +187,15 @@ public String toString()
   @Override
   public ExprEval eval(ObjectBinding bindings)
   {
-    return function.apply(args, bindings);
+    try {
+      return function.apply(args, bindings);
+    }
+    catch (DruidException | ExpressionValidationException e) {
+      throw e;
+    }
+    catch (Exception e) {
+      throw DruidException.defensive().build(e, "Invocation of function '%s' 
encountered exception.", name);

Review Comment:
   In case the invoked function have already thrown out some reasonable 
exception (`DruidException`) - that's not touched at all - because a catch 
above caught it.
   
   I wanted to add this to catch cases in which some unexpected issue happened 
while the function was processing....so that we don't let out a 
`NullPointerException` ; instead say that "Invocation of function x encountered 
... " - it may give some help to the user what might have been the problem ; 
and it could give better error message to support instead of just refering to 
it as an NPE.
   
   or do you think it would be better to repackage also normal 
`DruidExcpetion`-s and re-packaged? - and rethrown them with a bit more context?
   so it will be something like:
   ```
   DruidException: while invoking function x
   caused by:
   DruidException: Can't process an empty set because it Sunday!
   ``
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to