Improve exception message for the Eval class

This commit is contained in:
Christian Koop 2022-06-16 13:21:58 +02:00
parent c33987162e
commit d25514743f
No known key found for this signature in database
GPG Key ID: 89A8181384E010A3
2 changed files with 2 additions and 2 deletions

View File

@ -32,7 +32,7 @@ public class Eval {
double x = parseExpression();
if (pos < toParse.length()) {
throw new RuntimeException(warningMessage + "Unexpected: " + (char) ch);
throw new RuntimeException(warningMessage + "Unexpected: '" + (char) ch + "' at position " + pos + " in '" + this.toParse + "'");
}
return x;

View File

@ -11,6 +11,6 @@ public class MathUtils {
}
public static double eval(String toParse, String warningMessage) {
return cache.computeIfAbsent(toParse, t -> new Eval(toParse, "[" + warningMessage + "]").parse());
return cache.computeIfAbsent(toParse, t -> new Eval(toParse, warningMessage).parse());
}
}