mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-25 17:27:00 +00:00
Let unexpected error write crash log
This commit is contained in:
parent
536744aac8
commit
29f2e4c0e6
2 changed files with 6 additions and 5 deletions
|
@ -47,7 +47,7 @@ public class ApplicationEx extends Application {
|
||||||
public void uncaughtException(Thread thread, Throwable ex) {
|
public void uncaughtException(Thread thread, Throwable ex) {
|
||||||
if (ownFault(ex)) {
|
if (ownFault(ex)) {
|
||||||
Log.e(Helper.TAG, ex + "\r\n" + Log.getStackTraceString(ex));
|
Log.e(Helper.TAG, ex + "\r\n" + Log.getStackTraceString(ex));
|
||||||
writeCrashLog(ex);
|
writeCrashLog(ApplicationEx.this, ex);
|
||||||
|
|
||||||
if (prev != null)
|
if (prev != null)
|
||||||
prev.uncaughtException(thread, ex);
|
prev.uncaughtException(thread, ex);
|
||||||
|
@ -110,17 +110,18 @@ public class ApplicationEx extends Application {
|
||||||
return true;
|
return true;
|
||||||
ex = ex.getCause();
|
ex = ex.getCause();
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeCrashLog(Throwable ex) {
|
static void writeCrashLog(Context context, Throwable ex) {
|
||||||
File file = new File(getCacheDir(), "crash.log");
|
File file = new File(context.getCacheDir(), "crash.log");
|
||||||
Log.w(Helper.TAG, "Writing exception to " + file);
|
Log.w(Helper.TAG, "Writing exception to " + file);
|
||||||
|
|
||||||
FileWriter out = null;
|
FileWriter out = null;
|
||||||
try {
|
try {
|
||||||
out = new FileWriter(file);
|
out = new FileWriter(file);
|
||||||
out.write(ex.toString() + "\n" + Log.getStackTraceString(ex));
|
out.write(ex + "\r\n" + Log.getStackTraceString(ex));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(Helper.TAG, e + "\n" + Log.getStackTraceString(e));
|
Log.e(Helper.TAG, e + "\n" + Log.getStackTraceString(e));
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -189,7 +189,7 @@ public class Helper {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void unexpectedError(final Context context, final LifecycleOwner owner, final Throwable ex) {
|
static void unexpectedError(final Context context, final LifecycleOwner owner, final Throwable ex) {
|
||||||
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex));
|
ApplicationEx.writeCrashLog(context, ex);
|
||||||
|
|
||||||
if (owner.getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
|
if (owner.getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
|
||||||
new DialogBuilderLifecycle(context, owner)
|
new DialogBuilderLifecycle(context, owner)
|
||||||
|
|
Loading…
Reference in a new issue