From b1f28d119cd1bd124e74f162f3f994732628a758 Mon Sep 17 00:00:00 2001 From: Lina Butler Date: Thu, 14 Dec 2023 08:53:15 -0800 Subject: [PATCH] Bug 1869225 - Catch `SuggestApiException`s. This commit adds a `handleSuggestExceptions` helper to `FxSuggestStorage` that catches and reports `SuggestApiException`s from the Suggest Rust component. `handleSuggestExceptions` works like the existing `handle{Fxa, Places}Exceptions` helpers. `FxSuggestIngestionWorker`'s retry behavior is unchanged: if ingestion fails, the exception will now be reported, but the operation will still be rescheduled using `WorkManager`'s retry mechanism, as before. (cherry picked from commit 2ffae770dca04824498315203182ce7b4e44c102) --- .../main/java/org/mozilla/fenix/components/Components.kt | 2 +- .../main/java/org/mozilla/fenix/components/FxSuggest.kt | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/components/Components.kt b/app/src/main/java/org/mozilla/fenix/components/Components.kt index fb5dc1072..0346f0b4f 100644 --- a/app/src/main/java/org/mozilla/fenix/components/Components.kt +++ b/app/src/main/java/org/mozilla/fenix/components/Components.kt @@ -227,7 +227,7 @@ class Components(private val context: Context) { ) } - val fxSuggest by lazyMonitored { FxSuggest(context) } + val fxSuggest by lazyMonitored { FxSuggest(context, analytics.crashReporter) } } /** diff --git a/app/src/main/java/org/mozilla/fenix/components/FxSuggest.kt b/app/src/main/java/org/mozilla/fenix/components/FxSuggest.kt index 05593c97f..22a444442 100644 --- a/app/src/main/java/org/mozilla/fenix/components/FxSuggest.kt +++ b/app/src/main/java/org/mozilla/fenix/components/FxSuggest.kt @@ -5,6 +5,7 @@ package org.mozilla.fenix.components import android.content.Context +import mozilla.components.concept.base.crash.CrashReporting import mozilla.components.feature.fxsuggest.FxSuggestIngestionScheduler import mozilla.components.feature.fxsuggest.FxSuggestStorage import org.mozilla.fenix.perf.lazyMonitored @@ -13,10 +14,12 @@ import org.mozilla.fenix.perf.lazyMonitored * Component group for Firefox Suggest. * * @param context The Android application context. + * @param crashReporter An optional [CrashReporting] instance for reporting unexpected caught + * exceptions. */ -class FxSuggest(context: Context) { +class FxSuggest(context: Context, crashReporter: CrashReporting? = null) { val storage by lazyMonitored { - FxSuggestStorage(context) + FxSuggestStorage(context, crashReporter) } val ingestionScheduler by lazyMonitored {