From 0708d84b98d352f7c89aa6454ba9bc7a9e7edcad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Borcz?= Date: Sun, 8 Apr 2018 17:34:18 +0200 Subject: [PATCH] Log non-fatal exceptions with fabric (#80) --- .../wulkanowy/data/db/resources/AppResources.java | 13 ++++++++----- .../java/io/github/wulkanowy/services/SyncJob.java | 2 ++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/github/wulkanowy/data/db/resources/AppResources.java b/app/src/main/java/io/github/wulkanowy/data/db/resources/AppResources.java index c35f44c7..5b1f8718 100644 --- a/app/src/main/java/io/github/wulkanowy/data/db/resources/AppResources.java +++ b/app/src/main/java/io/github/wulkanowy/data/db/resources/AppResources.java @@ -3,6 +3,8 @@ package io.github.wulkanowy.data.db.resources; import android.content.Context; import android.content.res.Resources; +import com.crashlytics.android.Crashlytics; + import java.io.IOException; import java.net.SocketTimeoutException; import java.net.UnknownHostException; @@ -41,6 +43,7 @@ public class AppResources implements ResourcesContract { @Override public String getErrorLoginMessage(Exception exception) { LogUtils.error(AppConstant.APP_NAME + " encountered a error", exception); + Crashlytics.logException(exception); if (exception instanceof CryptoException) { return resources.getString(R.string.encrypt_failed_text); @@ -64,23 +67,23 @@ public class AppResources implements ResourcesContract { } if (lesson.getIsAbsenceExcused()) { - id = R.string.attendance_absence_excused; + id = R.string.attendance_absence_excused; } if (lesson.getIsAbsenceUnexcused()) { - id = R.string.attendance_absence_unexcused; + id = R.string.attendance_absence_unexcused; } if (lesson.getIsExemption()) { - id = R.string.attendance_exemption; + id = R.string.attendance_exemption; } if (lesson.getIsExcusedLateness()) { - id = R.string.attendance_excused_lateness; + id = R.string.attendance_excused_lateness; } if (lesson.getIsUnexcusedLateness()) { - id = R.string.attendance_unexcused_lateness; + id = R.string.attendance_unexcused_lateness; } return resources.getString(id); diff --git a/app/src/main/java/io/github/wulkanowy/services/SyncJob.java b/app/src/main/java/io/github/wulkanowy/services/SyncJob.java index e91d5e7c..43cde908 100644 --- a/app/src/main/java/io/github/wulkanowy/services/SyncJob.java +++ b/app/src/main/java/io/github/wulkanowy/services/SyncJob.java @@ -4,6 +4,7 @@ import android.app.PendingIntent; import android.content.Context; import android.support.v4.app.NotificationCompat; +import com.crashlytics.android.Crashlytics; import com.firebase.jobdispatcher.Constraint; import com.firebase.jobdispatcher.FirebaseJobDispatcher; import com.firebase.jobdispatcher.GooglePlayDriver; @@ -75,6 +76,7 @@ public class SyncJob extends SimpleJobService { } return JobService.RESULT_SUCCESS; } catch (Exception e) { + Crashlytics.logException(e); LogUtils.error("During background synchronization an error occurred", e); return JobService.RESULT_FAIL_RETRY; }