Skip to content

Commit bac59f6

Browse files
committed
Merge 2 mapCatchingExceptions into a single one.
1 parent d277a60 commit bac59f6

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

libraries/wellknown/impl/src/main/kotlin/io/element/android/libraries/wellknown/impl/DefaultSessionWellknownRetriever.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ class DefaultSessionWellknownRetriever @Inject constructor(
2929
val url = "https://$domain/.well-known/matrix/client"
3030
return matrixClient
3131
.getUrl(url)
32-
.mapCatchingExceptions { String(it) }
33-
.mapCatchingExceptions { parser.decodeFromString(InternalWellKnown.serializer(), it) }
32+
.mapCatchingExceptions {
33+
val data = String(it)
34+
parser.decodeFromString(InternalWellKnown.serializer(), data)
35+
}
3436
.onFailure { Timber.e(it, "Failed to retrieve .well-known from $domain") }
3537
.map { it.map() }
3638
.getOrNull()
@@ -40,8 +42,10 @@ class DefaultSessionWellknownRetriever @Inject constructor(
4042
val url = "https://$domain/.well-known/element/element.json"
4143
return matrixClient
4244
.getUrl(url)
43-
.mapCatchingExceptions { String(it) }
44-
.mapCatchingExceptions { parser.decodeFromString(InternalElementWellKnown.serializer(), it) }
45+
.mapCatchingExceptions {
46+
val data = String(it)
47+
parser.decodeFromString(InternalElementWellKnown.serializer(), data)
48+
}
4549
.onFailure { Timber.e(it, "Failed to retrieve Element .well-known from $domain") }
4650
.map { it.map() }
4751
.getOrNull()

0 commit comments

Comments
 (0)