From feb9110f47e0d80bd04f3d12d32f653ac45ad8e3 Mon Sep 17 00:00:00 2001 From: Kirill Kamakin Date: Wed, 21 Dec 2022 22:39:09 +0100 Subject: [PATCH] Remove Exception name from error messages --- .../main/kotlin/gq/kirmanak/mealient/datasource/NetworkError.kt | 2 +- .../gq/kirmanak/mealient/datasource/impl/BaseUrlInterceptor.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/datasource/src/main/kotlin/gq/kirmanak/mealient/datasource/NetworkError.kt b/datasource/src/main/kotlin/gq/kirmanak/mealient/datasource/NetworkError.kt index 50953a4..024c234 100644 --- a/datasource/src/main/kotlin/gq/kirmanak/mealient/datasource/NetworkError.kt +++ b/datasource/src/main/kotlin/gq/kirmanak/mealient/datasource/NetworkError.kt @@ -1,6 +1,6 @@ package gq.kirmanak.mealient.datasource -sealed class NetworkError(cause: Throwable) : RuntimeException(cause) { +sealed class NetworkError(cause: Throwable) : RuntimeException(cause.message, cause) { class Unauthorized(cause: Throwable) : NetworkError(cause) class NoServerConnection(cause: Throwable) : NetworkError(cause) class NotMealie(cause: Throwable) : NetworkError(cause) diff --git a/datasource/src/main/kotlin/gq/kirmanak/mealient/datasource/impl/BaseUrlInterceptor.kt b/datasource/src/main/kotlin/gq/kirmanak/mealient/datasource/impl/BaseUrlInterceptor.kt index b64ae1f..8796804 100644 --- a/datasource/src/main/kotlin/gq/kirmanak/mealient/datasource/impl/BaseUrlInterceptor.kt +++ b/datasource/src/main/kotlin/gq/kirmanak/mealient/datasource/impl/BaseUrlInterceptor.kt @@ -38,6 +38,6 @@ 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) }.getOrThrow() + url.runCatching { toHttpUrl() }.recover { throw IOException(it.message, it) }.getOrThrow() } } \ No newline at end of file