forked from ChomeNS/chomens-bot-java
uncaught exception handler thing
it also exists in java yes
This commit is contained in:
parent
7c1063daa3
commit
92dffdc2ed
1 changed files with 14 additions and 0 deletions
|
@ -2,6 +2,7 @@ package land.chipmunk.chayapak.chomens_bot;
|
||||||
|
|
||||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||||
import land.chipmunk.chayapak.chomens_bot.plugins.ConsolePlugin;
|
import land.chipmunk.chayapak.chomens_bot.plugins.ConsolePlugin;
|
||||||
|
import land.chipmunk.chayapak.chomens_bot.util.ExceptionUtilities;
|
||||||
import land.chipmunk.chayapak.chomens_bot.util.HttpUtilities;
|
import land.chipmunk.chayapak.chomens_bot.util.HttpUtilities;
|
||||||
import land.chipmunk.chayapak.chomens_bot.util.LoggerUtilities;
|
import land.chipmunk.chayapak.chomens_bot.util.LoggerUtilities;
|
||||||
import net.dv8tion.jda.api.JDA;
|
import net.dv8tion.jda.api.JDA;
|
||||||
|
@ -82,6 +83,19 @@ public class Main {
|
||||||
}
|
}
|
||||||
}, 0, 1, TimeUnit.MINUTES);
|
}, 0, 1, TimeUnit.MINUTES);
|
||||||
|
|
||||||
|
Thread.currentThread().setUncaughtExceptionHandler((thread, throwable) -> {
|
||||||
|
LoggerUtilities.error(
|
||||||
|
String.format(
|
||||||
|
"Caught an uncaught exception in thread %s!\n%s",
|
||||||
|
|
||||||
|
thread.getName(),
|
||||||
|
ExceptionUtilities.getStacktrace(throwable)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (throwable instanceof OutOfMemoryError) System.exit(1);
|
||||||
|
});
|
||||||
|
|
||||||
if (!config.backup.enabled) {
|
if (!config.backup.enabled) {
|
||||||
initializeBots();
|
initializeBots();
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue