forked from StarOpenSource/Engine
Replace executeSafely with good 'ol try-catch
This commit is contained in:
parent
5284dfe17b
commit
f1fb21dbb1
1 changed files with 4 additions and 17 deletions
|
@ -22,12 +22,10 @@ package de.staropensource.sosengine.testapp;
|
|||
import de.staropensource.sosengine.base.Engine;
|
||||
import de.staropensource.sosengine.base.annotations.EventListener;
|
||||
import de.staropensource.sosengine.base.data.versioning.OneNumberVersioningSystem;
|
||||
import de.staropensource.sosengine.base.events.ThrowableCatchEvent;
|
||||
import de.staropensource.sosengine.base.logging.LoggerInstance;
|
||||
import de.staropensource.sosengine.base.types.DependencyVector;
|
||||
import de.staropensource.sosengine.base.types.vectors.Vec2i;
|
||||
import de.staropensource.sosengine.base.utility.DependencyResolver;
|
||||
import de.staropensource.sosengine.base.utility.Miscellaneous;
|
||||
import de.staropensource.sosengine.base.utility.parser.StackTraceParser;
|
||||
import de.staropensource.sosengine.windowing.WindowingSubsystem;
|
||||
import de.staropensource.sosengine.windowing.classes.Window;
|
||||
|
@ -119,7 +117,7 @@ public final class Main {
|
|||
*/
|
||||
@SneakyThrows
|
||||
public void run() {
|
||||
Miscellaneous.executeSafely(() -> {
|
||||
try {
|
||||
// Initialize sos!engine
|
||||
engine = new Engine();
|
||||
|
||||
|
@ -223,20 +221,9 @@ public final class Main {
|
|||
}
|
||||
|
||||
logger.crash(message.toString());
|
||||
}, "mainThread");
|
||||
} catch (Exception exception) {
|
||||
logger.crash("The main thread threw an exception", exception);
|
||||
}
|
||||
|
||||
/**
|
||||
* Crashes the application when a throwable
|
||||
* is thrown in {@link #run()}.
|
||||
*
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
@EventListener(event = ThrowableCatchEvent.class)
|
||||
@SuppressWarnings({ "unused" })
|
||||
private static void onThrowable(@NotNull Throwable throwable, @NotNull String identifier) {
|
||||
if (identifier.equals("mainThread") && instance != null)
|
||||
instance.logger.crash("The main thread threw an exception", throwable);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue