Fix unhandled exceptions when evaluating operators (#1344)
This commit is contained in:
1 parent
692e157905
commit
e011f65e75
1 file changed
+9
-5
@@ -238,14 +238,16 @@ public abstract class Fluff
|
|||||||
@Override
|
@Override
|
||||||
public LazyValue lazyEval(Context cc, Context.Type type, Expression e, Tokenizer.Token t, final LazyValue v1, final LazyValue v2)
|
public LazyValue lazyEval(Context cc, Context.Type type, Expression e, Tokenizer.Token t, final LazyValue v1, final LazyValue v2)
|
||||||
{
|
{
|
||||||
|
return (c, typeIgnored) -> {
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return (c, type_ignored) -> AbstractOperator.this.eval(v1.evalValue(c, Context.Type.NONE), v2.evalValue(c, Context.Type.NONE));
|
return AbstractOperator.this.eval(v1.evalValue(c, Context.Type.NONE), v2.evalValue(c, Context.Type.NONE));
|
||||||
}
|
}
|
||||||
catch (RuntimeException exc)
|
catch (RuntimeException exc)
|
||||||
{
|
{
|
||||||
throw Expression.handleCodeException(cc, exc, e, t);
|
throw Expression.handleCodeException(cc, exc, e, t);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,25 +268,27 @@ public abstract class Fluff
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LazyValue lazyEval(Context cc, Context.Type type, Expression e, Tokenizer.Token t, final LazyValue v1, final LazyValue v2)
|
public LazyValue lazyEval(Context cc, Context.Type type, Expression e, Tokenizer.Token t, final LazyValue v1, final LazyValue v2)
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
if (v2 != null)
|
if (v2 != null)
|
||||||
{
|
{
|
||||||
throw new ExpressionException(cc, e, t, "Did not expect a second parameter for unary operator");
|
throw new ExpressionException(cc, e, t, "Did not expect a second parameter for unary operator");
|
||||||
}
|
}
|
||||||
return (c, ignored_type) -> AbstractUnaryOperator.this.evalUnary(v1.evalValue(c, Context.Type.NONE));
|
return (c, ignoredType) -> {
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return AbstractUnaryOperator.this.evalUnary(v1.evalValue(c, Context.Type.NONE));
|
||||||
}
|
}
|
||||||
catch (RuntimeException exc)
|
catch (RuntimeException exc)
|
||||||
{
|
{
|
||||||
throw Expression.handleCodeException(cc, exc, e, t);
|
throw Expression.handleCodeException(cc, exc, e, t);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Value eval(Value v1, Value v2)
|
public Value eval(Value v1, Value v2)
|
||||||
{
|
{
|
||||||
throw new RuntimeException("Shouldn't end up here");
|
throw new IllegalStateException("Shouldn't end up here");
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract Value evalUnary(Value v1);
|
public abstract Value evalUnary(Value v1);
|
||||||
|
|||||||
Reference in new issue
Block a user