FerriteCore icon indicating copy to clipboard operation
FerriteCore copied to clipboard

Crash on startup - `FerriteConfig` hides exceptions raised in `ConfigFileHandler` by not unwrapping the underlying `InvocationTargetException`

Open alcatrazEscapee opened this issue 9 months ago • 3 comments

Minecraft 1.20.1 Mod Loader Lex Forge Forge 47.2.23 Ferrite Core 6.0.1 Crash Log https://paste.ee/p/ITjLM

This crash log is particularly hard to decipher, because the crash originates from here:

Caused by: java.lang.NoClassDefFoundError: Could not initialize class malte0811.ferritecore.mixin.config.FerriteConfig
...
Caused by: java.lang.ExceptionInInitializerError: Exception java.lang.RuntimeException: java.lang.reflect.InvocationTargetException [in thread "main"]
	at TRANSFORMER/[email protected]/malte0811.ferritecore.mixin.config.FerriteConfig$ConfigBuilder.finish(FerriteConfig.java:100)
	at TRANSFORMER/[email protected]/malte0811.ferritecore.mixin.config.FerriteConfig.<clinit>(FerriteConfig.java:75)
	at TRANSFORMER/[email protected]/malte0811.ferritecore.mixin.predicates.Config.<init>(Config.java:8)

This appears because FerriteConfig tries to reflectively invoke a method, and then immediately wrap any exceptions thrown in a RuntimeException, it hides the underlying cause (which would be whatever error was thrown in the reflectively invoked method itself:

https://github.com/malte0811/FerriteCore/blob/e47bcbbde5b83805f927bad82bcc2b323e7169b8/Common/src/main/java/malte0811/ferritecore/mixin/config/FerriteConfig.java#L94-L101

Ideally, this should catch InvocationTargetExceptions, and throw a new RuntimeError(e.getCause()), as that would be the actual underlying error being thrown. Beyond that, FerriteCore is crashing on startup here with unclear cause, but the problem appears to be directly related to whatever ConfigFileHandler is doing, which seems to crash loading the mixin config plugin.

alcatrazEscapee avatar May 10 '24 12:05 alcatrazEscapee