Handle breaking changes from a-s 83.0.0 (#21215)

upstream-sync
bendk 3 years ago committed by GitHub
parent cd053f2a9a
commit 5ba47a90db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -13,7 +13,7 @@ import mozilla.components.service.nimbus.NimbusAppInfo
import mozilla.components.service.nimbus.NimbusDisabled
import mozilla.components.service.nimbus.NimbusServerSettings
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.R
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 ->
Logger.error("Nimbus error: $message", e)
if (e is NimbusErrorException && !e.isReportableError()) {
if (e is NimbusException && !e.isReportableError()) {
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
*/
fun NimbusErrorException.isReportableError(): Boolean {
fun NimbusException.isReportableError(): Boolean {
return when (this) {
is NimbusErrorException.RequestError,
is NimbusErrorException.ResponseError -> false
is NimbusException.RequestException,
is NimbusException.ResponseException -> false
else -> true
}
}

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

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

Loading…
Cancel
Save