This commit is contained in:
gnembon committed 2021-03-09 14:43:29 -04:00
1 parent 72af3f732e
commit 29893ed28a
2 files changed
+12 -12

No files matched your search

@@ -16,7 +16,7 @@ public class ExpressionException extends RuntimeException implements ResolvedExc
public final Context context;
public final Tokenizer.Token token;
public final List<FunctionValue> stack = new ArrayList<>();
private final Supplier<String> lazyStacktrace;
private final Supplier<String> lazyMessage;
private String cachedMessage = null;
public ExpressionException(Context c, Expression e, String message)
@@ -27,7 +27,7 @@ public class ExpressionException extends RuntimeException implements ResolvedExc
public ExpressionException(Context c, Expression e, Tokenizer.Token t, String message)
{
super("Error");
lazyStacktrace = () -> makeMessage(c, e, t, message);
lazyMessage = () -> makeMessage(c, e, t, message);
token = t;
context = c;
}
@@ -35,7 +35,7 @@ public class ExpressionException extends RuntimeException implements ResolvedExc
{
super("Error");
this.stack.addAll(stack);
lazyStacktrace = () -> makeMessage(c, e, t, message);
lazyMessage = () -> makeMessage(c, e, t, message);
token = t;
context = c;
}
@@ -44,7 +44,7 @@ public class ExpressionException extends RuntimeException implements ResolvedExc
{
super("Error");
this.stack.addAll(stack);
lazyStacktrace = () -> makeMessage(c, e, t, messageSupplier.get());
lazyMessage = () -> makeMessage(c, e, t, messageSupplier.get());
token = t;
context = c;
}
@@ -89,7 +89,7 @@ public class ExpressionException extends RuntimeException implements ResolvedExc
public String getMessage() {
if (cachedMessage == null)
{
cachedMessage = lazyStacktrace.get();
cachedMessage = lazyMessage.get();
}
return cachedMessage;
}
@@ -8,8 +8,8 @@ import carpet.script.value.Value;
public class ThrowStatement extends InternalExpressionException
{
private final Throwables thrownExceptionType;
private final Value exceptionData;
private final Throwables type;
private final Value data;
/**
* Creates a throw exception from a value, and assigns it a specified message.
@@ -20,8 +20,8 @@ public class ThrowStatement extends InternalExpressionException
public ThrowStatement(Value data, Throwables type)
{
super(type.getId());
exceptionData = data;
thrownExceptionType = type;
this.data = data;
this.type = type;
}
/**
@@ -36,12 +36,12 @@ public class ThrowStatement extends InternalExpressionException
public ThrowStatement(String message, Throwables type)
{
super(type.getId());
this.exceptionData = StringValue.of(message);
this.thrownExceptionType = type;
this.data = StringValue.of(message);
this.type = type;
}
@Override
public ExpressionException promote(Context c, Expression e, Token token) {
return new ProcessedThrowStatement(c, e, token, stack, thrownExceptionType, exceptionData);
return new ProcessedThrowStatement(c, e, token, stack, type, data);
}
}