mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-18 19:39:22 +00:00
Add option to completely hide a crash-callable depending on a runtime value (#9372)
This commit is contained in:
1 parent
7b8ca60d32
commit
684d36201f
5 files changed
+118
-8
No files matched your search
@@ -26,9 +26,12 @@ public class CrashReportExtender
|
||||
|
||||
public static void extendSystemReport(final SystemReport systemReport)
|
||||
{
|
||||
for (final ISystemReportExtender call: CrashReportCallables.allCrashCallables())
|
||||
for (final ISystemReportExtender call : CrashReportCallables.allCrashCallables())
|
||||
{
|
||||
systemReport.setDetail(call.getLabel(), call);
|
||||
if (call.isActive())
|
||||
{
|
||||
systemReport.setDetail(call.getLabel(), call);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.debug;
|
||||
|
||||
import net.minecraftforge.fml.CrashReportCallables;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
/**
|
||||
* Test features and guards of crash-callables.
|
||||
* <ul>
|
||||
* <li>The "AlwaysActiveCrashCallable" must always be printed to the crash report</li>
|
||||
* <li>The "ToggleableCrashCallable" must only be printed to the crash report when the {@code ENABLED} flag is {@code true}</li>
|
||||
* <li>The "BadContentCrashCallable" must always print "BadContentCrashCallable: ERR" to the crash report and
|
||||
* print an exception to the log (relies on a try-catch in vanilla code)</li>
|
||||
* <li>The "BadFlagCrashCallable" must never print to the crash report and must print an exception to the log</li>
|
||||
* </ul>
|
||||
* To initiate a debug crash to test this, hold F3 + C for 10 seconds.
|
||||
*/
|
||||
@Mod("crash_callable_test")
|
||||
public class CrashCallableTest
|
||||
{
|
||||
private static final boolean ENABLED = true;
|
||||
|
||||
public CrashCallableTest()
|
||||
{
|
||||
CrashReportCallables.registerCrashCallable("AlwaysActiveCrashCallable", () -> "test");
|
||||
CrashReportCallables.registerCrashCallable("ToggleableCrashCallable", () -> "active", () -> ENABLED);
|
||||
CrashReportCallables.registerCrashCallable("BadContentCrashCallable", () ->
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
});
|
||||
CrashReportCallables.registerCrashCallable("BadFlagCrashCallable", () -> "why am I here?!", () ->
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,8 @@ license="LGPL v2.1"
|
||||
modId="advancement_event_test"
|
||||
[[mods]]
|
||||
modId="shader_resources_test"
|
||||
[[mods]]
|
||||
modId="crash_callable_test"
|
||||
|
||||
# LEGACY TEST CASES
|
||||
###### The mods below are from the old test framework and need to be yeeted later again.
|
||||
|
||||
Reference in new issue
Block a user