diff --git a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/rest/RestUtils.kt b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/rest/RestUtils.kt index be5b12e..f499cdc 100644 --- a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/rest/RestUtils.kt +++ b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/rest/RestUtils.kt @@ -30,10 +30,14 @@ suspend fun maybeResponse(r: HttpResponse?): SuccessResponse { } suspend inline fun bodyOrFailure(r: HttpResponse?): StatusAndData { - return if (r != null && r.status.isSuccess()) { - StatusAndData.succes(r.body()) - } else { - StatusAndData.error() + try { + return if (r != null && r.status.isSuccess()) { + StatusAndData.succes(r.body()) + } else { + StatusAndData.error() + } + } catch (e: Throwable) { + return StatusAndData.error() } } @@ -94,4 +98,4 @@ suspend fun HttpClient.tryToSubmitForm( url(url) block() } - } + } \ No newline at end of file