From 75a6bf30416ed7569301d36e2b738b21cfc79511 Mon Sep 17 00:00:00 2001 From: Shubham Goyal Date: Tue, 10 Dec 2024 15:14:41 +0530 Subject: [PATCH 1/2] report non fatals to firebase --- app/src/org/commcare/logging/AndroidLogger.java | 5 +++++ app/src/org/commcare/logging/PreInitLogger.java | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/app/src/org/commcare/logging/AndroidLogger.java b/app/src/org/commcare/logging/AndroidLogger.java index 338648d52c..2b1d4ede21 100755 --- a/app/src/org/commcare/logging/AndroidLogger.java +++ b/app/src/org/commcare/logging/AndroidLogger.java @@ -82,4 +82,9 @@ public int logSize() { public void halt() { //Meh. } + + @Override + public void logException(Throwable e) { + CrashUtil.reportException(e); + } } diff --git a/app/src/org/commcare/logging/PreInitLogger.java b/app/src/org/commcare/logging/PreInitLogger.java index 40e485a525..2670f06354 100755 --- a/app/src/org/commcare/logging/PreInitLogger.java +++ b/app/src/org/commcare/logging/PreInitLogger.java @@ -1,6 +1,7 @@ package org.commcare.logging; import org.commcare.android.javarosa.AndroidLogEntry; +import org.commcare.utils.CrashUtil; import org.javarosa.core.api.ILogger; import org.javarosa.core.log.IFullLogSerializer; import org.javarosa.core.log.StreamLogSerializer; @@ -72,4 +73,9 @@ public int logSize() { public void halt() { // TODO Auto-generated method stub } + + @Override + public void logException(Throwable e) { + CrashUtil.reportException(e); + } } From 4de1c0b6923f6f8dc20cf27bd460a360f0c77231 Mon Sep 17 00:00:00 2001 From: Shubham Goyal Date: Wed, 11 Dec 2024 21:28:07 +0530 Subject: [PATCH 2/2] logs full exceptions --- app/src/org/commcare/tasks/templates/CommCareTask.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/src/org/commcare/tasks/templates/CommCareTask.java b/app/src/org/commcare/tasks/templates/CommCareTask.java index 3bf2aebb9f..4f0998643d 100755 --- a/app/src/org/commcare/tasks/templates/CommCareTask.java +++ b/app/src/org/commcare/tasks/templates/CommCareTask.java @@ -39,17 +39,15 @@ protected final Result doInBackground(Params... params) { try { return doTaskBackground(params); } catch (Exception e) { - Logger.log(TAG, "Error during task execution: " + e.getMessage()); - e.printStackTrace(); - if (!(e instanceof UserCausedRuntimeException)) { // Report crashes we know weren't caused by user misconfiguration - CrashUtil.reportException(e); + Logger.exception("Error during task execution: ", e); + } else { + Logger.log(TAG, "Error during task execution: " + e.getMessage()); } // Save error for reporting during post-execute unknownError = e; - return null; } }