From d58ebb8b71c207e0bcedcf14b67ed92efc9b5bd5 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 21 Mar 2022 17:44:07 +0100 Subject: [client] Install default thread exception handler --- .../src/main/java/org/openslx/dozmod/App.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/App.java b/dozentenmodul/src/main/java/org/openslx/dozmod/App.java index e7242a6f..36ea083b 100755 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/App.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/App.java @@ -134,6 +134,14 @@ public class App { MessageType.ERROR, LOGGER, e); return; } + + // Do this early on, before we start fiddling with threads + Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + LOGGER.warn("Uncaught Exception in thread " + t.getName(), e); + } + }); final String logFilePath = setupFileLogger(); AppUtil.logHeader(LOGGER, Branding.getApplicationName(), App.class.getPackage().getImplementationVersion()); @@ -247,7 +255,15 @@ public class App { ThriftManager.setMasterServerAddress(null, host, port, THRIFT_TIMEOUT_MS); } - // Setup global thrift connection error handler and then open the GUI + // Now change the default exception handler to the GUI one + Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + Gui.asyncMessageBox(I18n.APP.getString("App.Message.warning.uncaughtException", t.getName()), + MessageType.WARNING, LOGGER, e); + } + }); + // Setup GUI thread exception handler and then open the GUI SwingUtilities.invokeLater(new Runnable() { @Override public void run() { -- cgit v1.2.3-55-g7522