Skip to content

Commit 0d742fe

Browse files
committed
Make OkHttp coroutine calls always throw exceptions on errors
1 parent 6accf5e commit 0d742fe

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

app/src/main/java/eu/kanade/tachiyomi/data/updater/devrepo/DevRepoUpdateChecker.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class DevRepoUpdateChecker : UpdateChecker() {
2626

2727
override suspend fun checkForUpdate(): UpdateResult {
2828
val response = withContext(Dispatchers.IO) {
29-
client.newCall(GET(DevRepoRelease.LATEST_URL)).await(assertSuccess = false)
29+
client.newCall(GET(DevRepoRelease.LATEST_URL)).await()
3030
}
3131

3232
// Get latest repo version number from header in format "Location: tachiyomi-r1512.apk"

app/src/main/java/eu/kanade/tachiyomi/network/OkHttpExtensions.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ fun Call.asObservableWithAsyncStacktrace(): Observable<Pair<Exception, Response>
6464
fun Call.asObservable() = asObservableWithAsyncStacktrace().map { it.second }
6565

6666
// Based on https://github.com/gildor/kotlin-coroutines-okhttp
67-
suspend fun Call.await(assertSuccess: Boolean = false): Response {
67+
suspend fun Call.await(): Response {
6868
return suspendCancellableCoroutine { continuation ->
6969
enqueue(object : Callback {
7070
override fun onResponse(call: Call, response: Response) {
71-
if (assertSuccess && !response.isSuccessful) {
71+
if (!response.isSuccessful) {
7272
continuation.resumeWithException(Exception("HTTP error ${response.code}"))
7373
return
7474
}

0 commit comments

Comments
 (0)