Sistemata gestione delle eccezioni non gestite e creato sistema di esportazione Log

This commit is contained in:
2023-02-20 17:10:50 +01:00
parent 51c5d3a0c7
commit 25813a6362
15 changed files with 251 additions and 85 deletions

View File

@@ -3,11 +3,13 @@ package it.integry.integrywmsnative;
import android.app.Application;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.util.Log;
import javax.inject.Inject;
import it.integry.integrywmsnative.core.context.AppContext;
import it.integry.integrywmsnative.core.data_store.db.RoomModule;
import it.integry.integrywmsnative.core.utility.UtilityLogger;
public class MainApplication extends Application {
@@ -19,6 +21,8 @@ public class MainApplication extends Application {
public static MainApplicationModule appModule;
public static RoomModule roomModule;
private Thread.UncaughtExceptionHandler defaultUncaughtExceptionHandler;
@Inject
AppContext appContext;
@@ -40,6 +44,9 @@ public class MainApplication extends Application {
appComponent.inject(this);
res = getResources();
defaultUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
Thread.setDefaultUncaughtExceptionHandler(_unCaughtExceptionHandler);
}
// Called by the system when the device configuration changes while your component is running.
@@ -61,4 +68,22 @@ public class MainApplication extends Application {
System.exit(0);
}
// handler listener
private Thread.UncaughtExceptionHandler _unCaughtExceptionHandler =
new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread thread, Throwable ex) {
try {
UtilityLogger.error(new Exception(ex));
} catch (Exception e) {
Log.e("Uncaught error", "Exception Logger failed!", e);
//MainApplication.exit();
}
// re-throw critical exception further to the os (important)
defaultUncaughtExceptionHandler.uncaughtException(thread, ex);
}
};
}