Skip to content

Commit

Permalink
Tweak error messages when annotations are enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
misode committed Jan 25, 2024
1 parent 10704c3 commit 5adb26c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ minecraft_version=1.20.4
loader_version=0.15.0

# Mod Properties
mod_version=1.6.0-beta2
mod_version=1.6.0-beta3
maven_group=io.github.misode
archives_base_name=packtest

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static void error(Logger logger, String resource, String id, String messa
if (PackTest.isAnnotationsEnabled()) {
annotation = "\n::error title=Failed to load " + resource + " " + id + "::" + message;
}
logger.info(PackTest.wrapError("Failed to load {} {} - {}") + annotation, resource, id, message);
logger.info(PackTest.wrapError("Failed to load {} {}" + (PackTest.isAnnotationsEnabled() ? "" : " - {}")) + annotation, resource, id, message);
}

public static List<Diagnostic> loadErrors() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ private void onTestFailed(GameTestInfo info, CallbackInfo ci) {
String lineNumber = info.getError() instanceof LineNumberException err
? " on line " + err.getLineNumber()
: "";
String annotation = "";
if (PackTest.isAnnotationsEnabled() && info.isRequired()) {
annotation = "\n::error title=Test " + info.getTestName() + " failed" + lineNumber + "!::" + Util.describeError(info.getError());
}
if (info.isRequired()) {
LOGGER.error(PackTest.wrapError("{} failed{}! {}") + annotation, info.getTestName(), lineNumber, Util.describeError(info.getError()));
String annotation = "";
if (PackTest.isAnnotationsEnabled()) {
annotation = "\n::error title=Test " + info.getTestName() + " failed" + lineNumber + "!::" + Util.describeError(info.getError());
}
LOGGER.error(PackTest.wrapError("{} failed{}!" + (PackTest.isAnnotationsEnabled() ? "" : " {}")) + annotation, info.getTestName(), lineNumber, Util.describeError(info.getError()));
} else {
LOGGER.warn(PackTest.wrapWarning("(optional) {} failed{}! {}") + annotation, info.getTestName(), lineNumber, Util.describeError(info.getError()));
LOGGER.warn(PackTest.wrapWarning("(optional) {} failed{}! {}"), info.getTestName(), lineNumber, Util.describeError(info.getError()));
}
ci.cancel();
}
Expand Down

0 comments on commit 5adb26c

Please sign in to comment.