diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistInterceptor.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistInterceptor.kt index 07ac60111..8c21070c4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistInterceptor.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistInterceptor.kt @@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.data.track.anilist import okhttp3.Interceptor import okhttp3.Response +import java.io.IOException class AnilistInterceptor(val anilist: Anilist, private var token: String?) : Interceptor { @@ -28,12 +29,12 @@ class AnilistInterceptor(val anilist: Anilist, private var token: String?) : Int // Refresh access token if null or expired. if (oauth!!.isExpired()) { anilist.logout() - throw Exception("Token expired") + throw IOException("Token expired") } // Throw on null auth. if (oauth == null) { - throw Exception("No authentication token") + throw IOException("No authentication token") } // Add the authorization header to the original request. diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/BangumiInterceptor.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/BangumiInterceptor.kt index 033a167dc..899ca8782 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/BangumiInterceptor.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/BangumiInterceptor.kt @@ -16,15 +16,6 @@ class BangumiInterceptor(val bangumi: Bangumi) : Interceptor { */ private var oauth: OAuth? = bangumi.restoreToken() - fun addToken(token: String, oidFormBody: FormBody): FormBody { - val newFormBody = FormBody.Builder() - for (i in 0 until oidFormBody.size) { - newFormBody.add(oidFormBody.name(i), oidFormBody.value(i)) - } - newFormBody.add("access_token", token) - return newFormBody.build() - } - override fun intercept(chain: Interceptor.Chain): Response { val originalRequest = chain.request() @@ -65,4 +56,13 @@ class BangumiInterceptor(val bangumi: Bangumi) : Interceptor { bangumi.saveToken(oauth) } + + private fun addToken(token: String, oidFormBody: FormBody): FormBody { + val newFormBody = FormBody.Builder() + for (i in 0 until oidFormBody.size) { + newFormBody.add(oidFormBody.name(i), oidFormBody.value(i)) + } + newFormBody.add("access_token", token) + return newFormBody.build() + } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeListInterceptor.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeListInterceptor.kt index 50eb111a8..571b9a59f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeListInterceptor.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeListInterceptor.kt @@ -5,6 +5,7 @@ import kotlinx.serialization.json.Json import okhttp3.Interceptor import okhttp3.Response import uy.kohesive.injekt.injectLazy +import java.io.IOException class MyAnimeListInterceptor(private val myanimelist: MyAnimeList, private var token: String?) : Interceptor { @@ -16,7 +17,7 @@ class MyAnimeListInterceptor(private val myanimelist: MyAnimeList, private var t val originalRequest = chain.request() if (token.isNullOrEmpty()) { - throw Exception("Not authenticated with MyAnimeList") + throw IOException("Not authenticated with MyAnimeList") } if (oauth == null) { oauth = myanimelist.loadOAuth() @@ -30,7 +31,7 @@ class MyAnimeListInterceptor(private val myanimelist: MyAnimeList, private var t } } if (oauth == null) { - throw Exception("No authentication token") + throw IOException("No authentication token") } // Add the authorization header to the original request