From 187aa4c0fc07dcf6a27f2edb83b3d8163bef7420 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sun, 6 Jun 2021 16:25:02 +0800 Subject: Show gui for errors --- .../me/shedaniel/rei/fabric/PluginDetectorImpl.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'fabric/src/main/java') diff --git a/fabric/src/main/java/me/shedaniel/rei/fabric/PluginDetectorImpl.java b/fabric/src/main/java/me/shedaniel/rei/fabric/PluginDetectorImpl.java index 4e452bf16..5897f3864 100644 --- a/fabric/src/main/java/me/shedaniel/rei/fabric/PluginDetectorImpl.java +++ b/fabric/src/main/java/me/shedaniel/rei/fabric/PluginDetectorImpl.java @@ -24,6 +24,7 @@ package me.shedaniel.rei.fabric; import com.google.common.collect.Iterables; +import me.shedaniel.rei.RoughlyEnoughItemsState; import me.shedaniel.rei.api.client.plugins.REIClientPlugin; import me.shedaniel.rei.api.common.plugins.*; import net.fabricmc.api.EnvType; @@ -36,7 +37,6 @@ import java.util.function.Consumer; public class PluginDetectorImpl { private static

> void loadPlugin(Class pluginClass, Consumer> consumer) { - RuntimeException exception = null; for (EntrypointContainer container : Iterables.concat( FabricLoader.getInstance().getEntrypointContainers("rei_containers", REIPluginProvider.class), FabricLoader.getInstance().getEntrypointContainers("rei_server", REIPluginProvider.class), @@ -66,16 +66,17 @@ public class PluginDetectorImpl { }); } } catch (Throwable t) { - if (exception == null) { - exception = new RuntimeException("Could not create REI Plugin [" + pluginClass.getName() + "] due to errors, provided by '" + container.getProvider().getMetadata().getId() + "'!", t); - } else { - exception.addSuppressed(t); - } + String error = "Could not create REI Plugin [" + getSimpleName(pluginClass) + "] due to errors, provided by '" + container.getProvider().getMetadata().getId() + "'!"; + new RuntimeException(error, t).printStackTrace(); + RoughlyEnoughItemsState.error(error); } } - if (exception != null) { - throw exception; - } + } + + private static

String getSimpleName(Class pluginClass) { + String simpleName = pluginClass.getSimpleName(); + if (simpleName == null) return pluginClass.getName(); + return simpleName; } public static void detectServerPlugins() { -- cgit