From 09891bb0ad01e9b13d0f5b9404299c6779a0282c Mon Sep 17 00:00:00 2001 From: arkon Date: Mon, 3 Feb 2020 18:56:24 -0500 Subject: [PATCH] Throw exception in okhttp coroutine if response isn't successful --- .../java/eu/kanade/tachiyomi/network/OkHttpExtensions.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/src/main/java/eu/kanade/tachiyomi/network/OkHttpExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/network/OkHttpExtensions.kt index dc76ff0e7..14b7ec482 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/network/OkHttpExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/network/OkHttpExtensions.kt @@ -52,6 +52,11 @@ suspend fun Call.await(): Response { return suspendCancellableCoroutine { continuation -> enqueue(object : Callback { override fun onResponse(call: Call, response: Response) { + if (!response.isSuccessful) { + continuation.resumeWithException(Exception("HTTP error ${response.code}")) + return + } + continuation.resume(response) }