ezylang / EvalEx

EvalEx is a handy expression evaluator for Java, that allows to evaluate simple mathematical and boolean expressions.
https://ezylang.github.io/EvalEx/
Apache License 2.0
991 stars 270 forks source link

Management of the exception IndexOutOfBoundsException for Array variables #485

Closed karimall72 closed 3 months ago

karimall72 commented 4 months ago

Following expression will lead to a java.lang.IndexOutOfBoundsException:

EvaluationValue resultBadIndex = new Expression("MY_ARRAY[5]").with("MY_ARRAY", new int[] {1, 2}).evaluate();

According to me, it would be preferable to throw an EvalEx EvaluationException with the message related to the bad index (Index out of bound: Index 5 out of bounds for length 2)

Of course, the work around is easy (catch the IndexOutOfBoundsException), but I would consider my request as an improvement.