Handle all mod loading exceptions

This commit is contained in:
Bixilon 2020-11-22 19:40:59 +01:00
parent 82cd21ddf9
commit 0fba4510df
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4

View File

@ -23,7 +23,6 @@ import org.xeustechnologies.jcl.JarClassLoader;
import org.xeustechnologies.jcl.JclObjectFactory; import org.xeustechnologies.jcl.JclObjectFactory;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
@ -87,7 +86,12 @@ public class ModLoader {
progress.countDown(); progress.countDown();
return; return;
} }
try {
if (!instance.start(phase)) { if (!instance.start(phase)) {
throw new ModLoadingException(String.format("Could not load nod %s", instance.getInfo()));
}
} catch (Throwable e) {
e.printStackTrace();
Log.warn(String.format("An error occurred while loading %s", instance.getInfo())); Log.warn(String.format("An error occurred while loading %s", instance.getInfo()));
instance.setEnabled(false); instance.setEnabled(false);
} }
@ -127,7 +131,7 @@ public class ModLoader {
instance.setInfo(modInfo); instance.setInfo(modInfo);
Log.verbose(String.format("[MOD] Mod file loaded and added to classpath (%s)", modInfo)); Log.verbose(String.format("[MOD] Mod file loaded and added to classpath (%s)", modInfo));
zipFile.close(); zipFile.close();
} catch (IOException | ModLoadingException | NullPointerException e) { } catch (Throwable e) {
instance = null; instance = null;
e.printStackTrace(); e.printStackTrace();
Log.warn(String.format("Could not load mod: %s", file.getAbsolutePath())); Log.warn(String.format("Could not load mod: %s", file.getAbsolutePath()));