Added uncaught exception handler

This commit is contained in:
Sergey Karmanov 2020-11-19 18:27:44 +03:00
parent ec6181aaa8
commit 996a244649
2 changed files with 13 additions and 12 deletions

View File

@ -17,10 +17,23 @@
*******************************************************************************/ *******************************************************************************/
package ru.windcorp.progressia; package ru.windcorp.progressia;
import ru.windcorp.progressia.common.util.crash.CrashReports;
import ru.windcorp.progressia.common.util.crash.analyzers.OutOfMemoryAnalyzer;
import ru.windcorp.progressia.common.util.crash.providers.OSContextProvider;
public class ProgressiaLauncher { public class ProgressiaLauncher {
public static void launch(String[] args, Proxy proxy) { public static void launch(String[] args, Proxy proxy) {
setupCrashReports();
proxy.initialize(); proxy.initialize();
} }
private static void setupCrashReports() {
CrashReports.registerProvider(new OSContextProvider());
CrashReports.registerAnalyzer(new OutOfMemoryAnalyzer());
Thread.setDefaultUncaughtExceptionHandler((Thread thread, Throwable t)-> {
CrashReports.report(t,"Uncaught exception in thread %s", thread.getName());
});
}
} }

View File

@ -20,9 +20,6 @@ package ru.windcorp.progressia.client;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import ru.windcorp.progressia.ProgressiaLauncher; import ru.windcorp.progressia.ProgressiaLauncher;
import ru.windcorp.progressia.common.util.crash.CrashReports;
import ru.windcorp.progressia.common.util.crash.analyzers.OutOfMemoryAnalyzer;
import ru.windcorp.progressia.common.util.crash.providers.OSContextProvider;
public class ProgressiaClientMain { public class ProgressiaClientMain {
@ -31,15 +28,6 @@ public class ProgressiaClientMain {
public static void main(String[] args) { public static void main(String[] args) {
logger.info("App started!"); logger.info("App started!");
CrashReports.registerProvider(new OSContextProvider());
CrashReports.registerAnalyzer(new OutOfMemoryAnalyzer());
try {
@SuppressWarnings("unused")
long[] ssdss = new long[1 << 30];
} catch (Throwable t) {
CrashReports.report(t, "u %s stupid", "vry");
}
ProgressiaLauncher.launch(args, new ClientProxy()); ProgressiaLauncher.launch(args, new ClientProxy());
} }