feat: add uncaught exception handler
@@ -79,6 +79,7 @@ public abstract class EngineBase implements Engine {
logger.info("Initializing engine!");
+ initExceptionHandler();
initEnvironment();
printSystemInfo();
@@ -87,6 +88,14 @@ public abstract class EngineBase implements Engine {
loadMods();
}
+ private void initExceptionHandler() {
+ Thread.setDefaultUncaughtExceptionHandler((t, e) -> {
+ logger.error("Caught unhandled exception!!! Engine will terminate!", e);
+ // TODO: Crash report
+ System.exit(1);
+ });
+ }
+
private void initEnvironment() {
try {
if (Files.isDirectory(Path.of(this.getClass().getProtectionDomain().getCodeSource().getLocation().toURI()))) {
