debugging fixes

This commit is contained in:
Johannes Frohnmeyer 2023-06-29 16:40:37 +02:00
parent e61d3a19e8
commit 133929a116
Signed by: Johannes
GPG Key ID: E76429612C2929F4
3 changed files with 24 additions and 5 deletions

View File

@ -23,13 +23,18 @@ public class RpoClientCommand {
return 1;
};
Command<FabricClientCommandSource> dumpConfig = ctx -> {
MetaCache.forEach((id, branch) -> ctx.getSource().sendFeedback(dump(branch.toString(), id + ".txt")));
MetaCache.forEach((id, branch) -> ctx.getSource().sendFeedback(dump(branch.toString(), branch.packId() + ".txt")));
return 1;
};
Command<FabricClientCommandSource> dumpGlsl = ctx -> {
ctx.getSource().sendFeedback(dump(RespackoptsClient.getShaderImportSource(), "frex.glsl"));
return 1;
};
Command<FabricClientCommandSource> dumpScope = ctx -> {
ctx.getSource().sendFeedback(dump(MetaCache.getScope(null).toExpr().toString(), "_root.mu"));
MetaCache.forEach((id, branch) -> ctx.getSource().sendFeedback(dump(branch.executionScope().getOverrides().toExpr().toString(), branch.packId() + ".mu")));
return 1;
};
Command<FabricClientCommandSource> reload = ctx -> {
MetaCache.clear();
CompletableFuture.allOf(RespackoptsClient.forceReloadResources(), RespackoptsClient.reloadIntegratedServerData())
@ -45,6 +50,7 @@ public class RpoClientCommand {
dispatcher.register(literal("rpoc").executes(getVersion)
.then(literal("dump").executes(dumpConfig)
.then(literal("config").executes(dumpConfig))
.then(literal("scope").executes(dumpScope))
.then(literal("glsl").executes(dumpGlsl)))
.then(literal("version").executes(getVersion))
.then(literal("reload").executes(reload)));

View File

@ -16,7 +16,7 @@ public class FileExclusionProvider {
try {
return !rpo.condition.get(MetaCache.getScope(key));
} catch (Condition.ConditionException e) {
String res = "Could not evaluate condition " + file + " (pack: " + key.packName() + ")";
String res = "Could not evaluate condition for " + file + " (pack: " + key.packName() + ")";
try {
Respackopts.LOGGER.error(res + " with condition:\n" + ObjectGraphPrinter.printGraph(rpo.condition) + ")", e);
} catch (Throwable ex) {

View File

@ -5,15 +5,24 @@ import io.gitlab.jfronny.muscript.compiler.CodeLocation;
import io.gitlab.jfronny.muscript.data.Scope;
import io.gitlab.jfronny.muscript.error.LocationalException;
import io.gitlab.jfronny.muscript.error.PrettyPrintError;
import org.jetbrains.annotations.Nullable;
public record Condition(String source, String sourceFile, BoolExpr expr) {
public boolean get(Scope dataRoot) throws ConditionException {
try {
return expr.get(dataRoot);
} catch (LocationalException e) {
throw new ConditionException(e.asPrintable(), e);
throw new ConditionException(
e.asPrintable(),
"Your expression was optimized to: " + 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(), 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",
e
);
}
}
@ -25,7 +34,11 @@ public record Condition(String source, String sourceFile, BoolExpr expr) {
public final PrettyPrintError error;
public ConditionException(PrettyPrintError error, Throwable cause) {
super(error.toString(), cause);
this(error, null, cause);
}
public ConditionException(PrettyPrintError error, @Nullable String messageSuffix, Throwable cause) {
super(error.toString() + (messageSuffix == null ? "" : "\n" + messageSuffix), cause);
this.error = error;
}
}