Don't show error toasts in MangaController for HTTP 103 responses (closes #6562)

(cherry picked from commit 95b253db0984c87750b1cb284007754bf6c31880)

# Conflicts:
#	app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt
This commit is contained in:
arkon 2022-02-05 18:26:50 -05:00 committed by Jobobby04
parent 1fdede99a0
commit 75096e9808
2 changed files with 11 additions and 2 deletions

View File

@ -65,7 +65,7 @@ suspend fun Call.await(): Response {
object : Callback { object : Callback {
override fun onResponse(call: Call, response: Response) { override fun onResponse(call: Call, response: Response) {
if (!response.isSuccessful) { if (!response.isSuccessful) {
continuation.resumeWithException(Exception("HTTP error ${response.code}")) continuation.resumeWithException(HttpException(response.code))
return return
} }
@ -96,7 +96,7 @@ fun Call.asObservableSuccess(): Observable<Response> {
return asObservable().doOnNext { response -> return asObservable().doOnNext { response ->
if (!response.isSuccessful) { if (!response.isSuccessful) {
response.close() response.close()
throw Exception("HTTP error ${response.code}") throw HttpException(response.code)
} }
} }
} }
@ -123,3 +123,5 @@ inline fun <reified T> Response.parseAs(/* SY --> */ json: Json = Injekt.getInst
return json.decodeFromString(responseBody) return json.decodeFromString(responseBody)
} }
} }
class HttpException(val code: Int) : IllegalStateException("HTTP error $code")

View File

@ -49,6 +49,7 @@ import eu.kanade.tachiyomi.data.track.EnhancedTrackService
import eu.kanade.tachiyomi.data.track.TrackService import eu.kanade.tachiyomi.data.track.TrackService
import eu.kanade.tachiyomi.data.track.model.TrackSearch import eu.kanade.tachiyomi.data.track.model.TrackSearch
import eu.kanade.tachiyomi.databinding.MangaControllerBinding import eu.kanade.tachiyomi.databinding.MangaControllerBinding
import eu.kanade.tachiyomi.network.HttpException
import eu.kanade.tachiyomi.source.CatalogueSource import eu.kanade.tachiyomi.source.CatalogueSource
import eu.kanade.tachiyomi.source.LocalSource import eu.kanade.tachiyomi.source.LocalSource
import eu.kanade.tachiyomi.source.Source import eu.kanade.tachiyomi.source.Source
@ -585,6 +586,12 @@ class MangaController :
fun onFetchMangaInfoError(error: Throwable) { fun onFetchMangaInfoError(error: Throwable) {
isRefreshingInfo = false isRefreshingInfo = false
updateRefreshing() updateRefreshing()
// Ignore early hints "errors" that aren't handled by OkHttp
if (error is HttpException && error.code == 103) {
return
}
activity?.toast(error.message) activity?.toast(error.message)
} }