mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-13 02:21:14 +01:00
25 lines
753 B
Java
25 lines
753 B
Java
|
package nodomain.freeyourgadget.gadgetbridge;
|
||
|
|
||
|
|
||
|
import org.slf4j.Logger;
|
||
|
import org.slf4j.LoggerFactory;
|
||
|
|
||
|
public class LoggingExceptionHandler implements Thread.UncaughtExceptionHandler {
|
||
|
private static final Logger LOG = LoggerFactory.getLogger(LoggingExceptionHandler.class);
|
||
|
private final Thread.UncaughtExceptionHandler mDelegate;
|
||
|
|
||
|
public LoggingExceptionHandler(Thread.UncaughtExceptionHandler delegate) {
|
||
|
mDelegate = delegate;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void uncaughtException(Thread thread, Throwable ex) {
|
||
|
LOG.error("Uncaught exception: " + ex.getMessage(), ex);
|
||
|
if (mDelegate != null) {
|
||
|
mDelegate.uncaughtException(thread, ex);
|
||
|
} else {
|
||
|
System.exit(1);
|
||
|
}
|
||
|
}
|
||
|
}
|