Skip to content

Commit 79c917f

Browse files
carolkngpocmo
authored andcommitted
Catch all exceptions in safeAsync
1 parent 362423a commit 79c917f

File tree

1 file changed

+10
-5
lines changed
  • components/service/firefox-accounts/src/main/java/mozilla/components/service/fxa

1 file changed

+10
-5
lines changed

components/service/firefox-accounts/src/main/java/mozilla/components/service/fxa/RustObject.kt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,21 @@ abstract class RustObject<T> : Closeable {
5252
}
5353
}
5454

55+
@Suppress("TooGenericExceptionCaught")
5556
fun <U> safeAsync(callback: (Error.ByReference) -> U): FxaResult<U> {
5657
val result = FxaResult<U>()
5758
val e = Error.ByReference()
5859
launch {
5960
synchronized(FxaClient.INSTANCE) {
60-
val ret = callback(e)
61-
if (e.isFailure()) {
62-
result.completeExceptionally(FxaException.fromConsuming(e))
63-
} else {
64-
result.complete(ret)
61+
try {
62+
val ret = callback(e)
63+
if (e.isFailure()) {
64+
result.completeExceptionally(FxaException.fromConsuming(e))
65+
} else {
66+
result.complete(ret)
67+
}
68+
} catch (e: Exception) {
69+
result.completeExceptionally(e)
6570
}
6671
}
6772
}

0 commit comments

Comments
 (0)