[fenix] Handle breaking changes from a-s 83.0.0 (https://github.com/mozilla-mobile/fenix/pull/21215)

pull/600/head
bendk 3 years ago committed by GitHub
parent a9cdb1984c
commit 739d93372e

@ -13,7 +13,7 @@ import mozilla.components.service.nimbus.NimbusAppInfo
import mozilla.components.service.nimbus.NimbusDisabled import mozilla.components.service.nimbus.NimbusDisabled
import mozilla.components.service.nimbus.NimbusServerSettings import mozilla.components.service.nimbus.NimbusServerSettings
import mozilla.components.support.base.log.logger.Logger import mozilla.components.support.base.log.logger.Logger
import org.mozilla.experiments.nimbus.internal.NimbusErrorException import org.mozilla.experiments.nimbus.internal.NimbusException
import org.mozilla.fenix.BuildConfig import org.mozilla.fenix.BuildConfig
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.components
@ -24,7 +24,7 @@ fun createNimbus(context: Context, url: String?): NimbusApi {
val errorReporter: ((String, Throwable) -> Unit) = reporter@{ message, e -> val errorReporter: ((String, Throwable) -> Unit) = reporter@{ message, e ->
Logger.error("Nimbus error: $message", e) Logger.error("Nimbus error: $message", e)
if (e is NimbusErrorException && !e.isReportableError()) { if (e is NimbusException && !e.isReportableError()) {
return@reporter return@reporter
} }
@ -106,10 +106,10 @@ fun createNimbus(context: Context, url: String?): NimbusApi {
* *
* This fix should be upstreamed as part of: https://github.com/mozilla/application-services/issues/4333 * This fix should be upstreamed as part of: https://github.com/mozilla/application-services/issues/4333
*/ */
fun NimbusErrorException.isReportableError(): Boolean { fun NimbusException.isReportableError(): Boolean {
return when (this) { return when (this) {
is NimbusErrorException.RequestError, is NimbusException.RequestException,
is NimbusErrorException.ResponseError -> false is NimbusException.ResponseException -> false
else -> true else -> true
} }
} }

@ -7,20 +7,20 @@ package org.mozilla.fenix.experiments
import org.junit.Assert.assertFalse import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue import org.junit.Assert.assertTrue
import org.junit.Test import org.junit.Test
import org.mozilla.experiments.nimbus.internal.NimbusErrorException import org.mozilla.experiments.nimbus.internal.NimbusException
class NimbusSetupKtTest { class NimbusSetupKtTest {
@Test @Test
fun `WHEN error is reportable THEN return true`() { fun `WHEN error is reportable THEN return true`() {
val error = NimbusErrorException.IOError("bad error") val error = NimbusException.IOException("bad error")
assertTrue(error.isReportableError()) assertTrue(error.isReportableError())
} }
@Test @Test
fun `WHEN error is non-reportable THEN return false`() { fun `WHEN error is non-reportable THEN return false`() {
val error1 = NimbusErrorException.ResponseError("oops") val error1 = NimbusException.ResponseException("oops")
val error2 = NimbusErrorException.RequestError("oops") val error2 = NimbusException.RequestException("oops")
assertFalse(error1.isReportableError()) assertFalse(error1.isReportableError())
assertFalse(error2.isReportableError()) assertFalse(error2.isReportableError())

@ -3,5 +3,5 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
object AndroidComponents { object AndroidComponents {
const val VERSION = "94.0.20210909143340" const val VERSION = "94.0.20210909232434"
} }

Loading…
Cancel
Save