Simplify getBaseUrl method

This commit is contained in:
Kirill Kamakin
2022-12-22 18:43:18 +01:00
parent 05058091e9
commit 67eb1eca8b

View File

@@ -38,6 +38,11 @@ class BaseUrlInterceptor @Inject constructor(
private fun getBaseUrl() = runBlocking {
val url = serverUrlProvider.getUrl() ?: throw IOException("Base URL is unknown")
url.runCatching { toHttpUrl() }.recover { throw IOException(it.message, it) }.getOrThrow()
url.runCatching {
toHttpUrl()
}.fold(
onSuccess = { it },
onFailure = { throw IOException(it.message, it) },
)
}
}