mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-19 21:38:05 +01:00
Add uncaught exception handler
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright 2021 Signal Messenger, LLC
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package org.whispersystems.textsecuregcm.util.logging;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class UncaughtExceptionHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(UncaughtExceptionHandler.class);
|
||||
|
||||
public static void register() {
|
||||
@Nullable final Thread.UncaughtExceptionHandler current = Thread.getDefaultUncaughtExceptionHandler();
|
||||
|
||||
if (current != null) {
|
||||
logger.warn("Uncaught exception handler already exists: {}", current);
|
||||
return;
|
||||
}
|
||||
|
||||
Thread.setDefaultUncaughtExceptionHandler((t, e) -> logger.error("Uncaught exception on thread {}", t, e));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user