fix: use decompiler when visualizing optimized expression in condition exceptions
All checks were successful
ci/woodpecker/push/docs Pipeline was successful
ci/woodpecker/push/jfmod Pipeline was successful

This commit is contained in:
Johannes Frohnmeyer 2024-07-07 21:18:20 +02:00
parent cf7245c915
commit 65096a6ea4
Signed by: Johannes
GPG Key ID: E76429612C2929F4

View File

@ -7,6 +7,7 @@ import io.gitlab.jfronny.muscript.core.LocationalException;
import io.gitlab.jfronny.muscript.core.PrettyPrintError;
import io.gitlab.jfronny.muscript.data.additional.context.Scope;
import io.gitlab.jfronny.muscript.runtime.Runtime;
import io.gitlab.jfronny.muscript.serialize.Decompiler;
import io.gitlab.jfronny.respackopts.gson.ConditionDeserializer;
import org.jetbrains.annotations.Nullable;
@ -18,13 +19,13 @@ public record Condition(String source, String sourceFile, BoolExpr expr) {
} catch (LocationalException e) {
throw new ConditionException(
e.asPrintable(),
"Your expression was optimized to: " + expr + "\nRemember: You can use '/rpoc dump scope' to view your execution scope",
"Your expression was optimized to: " + Decompiler.decompile(expr) + "\nRemember: You can use '/rpoc dump scope' to view your execution scope",
e
);
} catch (RuntimeException e) {
throw new ConditionException(
PrettyPrintError.builder(new CodeLocation(0, 0, source, sourceFile)).setMessage(e.getMessage()).build(),
"Your expression was optimized to: " + expr + "\nRemember: You can use '/rpoc dump scope' to view your execution scope",
"Your expression was optimized to: " + Decompiler.decompile(expr) + "\nRemember: You can use '/rpoc dump scope' to view your execution scope",
e
);
}