From 1d99eeb633643dd25739680d2f6c660538b0465d Mon Sep 17 00:00:00 2001 From: Amine Date: Mon, 30 Dec 2024 13:51:45 +0100 Subject: [PATCH] bugfix: catch users using something other than selfoss. --- .../apps/readerforselfossv2/rest/RestUtils.kt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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