Make the null-result case visible to the user

Fixes #1303.

(cherry picked from commit 83438644dcdc470517f67c0d55ff4889f71cc435)
This commit is contained in:
Octavia Togami 2020-04-18 13:04:03 -07:00 committed by MattBDev
parent ee3a30d582
commit 3426e0103b

View File

@ -34,8 +34,6 @@ import java.time.Instant;
import java.util.List;
import java.util.Objects;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Compiles and evaluates expressions.
*
@ -122,7 +120,9 @@ public class Expression {
Instant deadline = Instant.now().plusMillis(timeout);
// evaluation exceptions are thrown out of this method
Double result = compiledExpression.execute(new ExecutionData(slots, functions, deadline));
checkNotNull(result, "Expression must result in a value");
if (result == null) {
throw new EvaluationException(-1, "Expression must result in a value");
}
return result;
}