mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-26 15:54:10 +00:00
Name skip origin frame
- Name the first Iris frame in skip warnings instead of the library frame that threw
This commit is contained in:
1 parent
ebe4aa1e41
commit
7b38f75846
2 files changed
+15
-5
No files matched your search
@@ -113,10 +113,10 @@ public final class GenerationFailures {
|
||||
StringBuilder line = new StringBuilder("Skipped ").append(kind).append(' ').append(block)
|
||||
.append(" at ").append(x).append(',').append(y).append(',').append(z)
|
||||
.append(" biome ").append(biome).append(": ").append(failure.getClass().getSimpleName()).append(message);
|
||||
StackTraceElement[] frames = failure.getStackTrace();
|
||||
if (frames.length > 0) {
|
||||
String file = frames[0].getFileName() == null ? frames[0].getClassName() : frames[0].getFileName().replace(".java", "");
|
||||
line.append(" (").append(file).append(':').append(frames[0].getLineNumber()).append(')');
|
||||
StackTraceElement origin = origin(failure);
|
||||
if (origin != null) {
|
||||
String className = origin.getClassName();
|
||||
line.append(" (").append(className.substring(className.lastIndexOf('.') + 1)).append('.').append(origin.getMethodName()).append(')');
|
||||
}
|
||||
if (suppressed > 0L) {
|
||||
line.append(", ").append(suppressed).append(" more");
|
||||
@@ -124,6 +124,16 @@ public final class GenerationFailures {
|
||||
return line.toString();
|
||||
}
|
||||
|
||||
private static StackTraceElement origin(Throwable failure) {
|
||||
StackTraceElement[] frames = failure.getStackTrace();
|
||||
for (StackTraceElement frame : frames) {
|
||||
if (frame.getClassName().startsWith("art.arcane.")) {
|
||||
return frame;
|
||||
}
|
||||
}
|
||||
return frames.length == 0 ? null : frames[0];
|
||||
}
|
||||
|
||||
private static final class SkipWarning {
|
||||
private final AtomicLong last;
|
||||
private final AtomicLong suppressed = new AtomicLong();
|
||||
|
||||
@@ -54,7 +54,7 @@ public class GenerationFailuresTest {
|
||||
String line = GenerationFailures.skipWarning("decoration", "minecraft:vine", 1, 2, 3, "test/biome",
|
||||
new IllegalArgumentException("Invalid\nblockFace"), 0L);
|
||||
assertEquals("Skipped decoration minecraft:vine at 1,2,3 biome test/biome: IllegalArgumentException: Invalid blockFace"
|
||||
+ " (GenerationFailuresTest:" + line.substring(line.lastIndexOf(':') + 1), line);
|
||||
+ " (GenerationFailuresTest.skipWarningNamesBlockPositionBiomeAndFailureOnOneLine)", line);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in new issue
Block a user