Replace Exception with IOException in interceptors to avoid crashes. (#11761)

This commit is contained in:
Alessandro Jean 2022-05-06 18:27:53 -03:00 committed by GitHub
parent 7d7e3d6f03
commit 9bff18b1fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 19 additions and 14 deletions

View File

@ -35,6 +35,7 @@ import rx.schedulers.Schedulers
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
import uy.kohesive.injekt.injectLazy
import java.io.IOException
import java.text.SimpleDateFormat
import java.util.Calendar
import java.util.Locale
@ -298,16 +299,16 @@ abstract class HentaiHand(
val body = jsonObject.toString().toRequestBody(MEDIA_TYPE)
val response = chain.proceed(POST("$baseUrl/api/login", headers, body))
if (response.code == 401) {
throw Exception("Failed to login, check if username and password are correct")
throw IOException("Failed to login, check if username and password are correct")
}
if (response.body == null)
throw Exception("Login response body is empty")
throw IOException("Login response body is empty")
try {
// Returns access token as a string, unless unparseable
return json.parseToJsonElement(response.body!!.string()).jsonObject["auth"]!!.jsonObject["access-token"]!!.jsonPrimitive.content
} catch (e: IllegalArgumentException) {
throw Exception("Cannot parse login response body")
throw IOException("Cannot parse login response body")
}
}

View File

@ -10,7 +10,7 @@ class HentaiHandGenerator : ThemeSourceGenerator {
override val themeClass = "HentaiHand"
override val baseVersionCode: Int = 1
override val baseVersionCode: Int = 2
override val sources = listOf(
MultiLang("HentaiHand", "https://hentaihand.com", listOf("all", "ja", "en", "zh", "bg", "ceb", "other", "tl", "ar", "el", "sr", "jv", "uk", "tr", "fi", "la", "mn", "eo", "sk", "cs", "ko", "ru", "it", "es", "pt-BR", "th", "fr", "id", "vi", "de", "pl", "hu", "nl", "hi"), isNsfw = true, overrideVersionCode = 5),

View File

@ -6,7 +6,7 @@ ext {
extName = 'Mango'
pkgNameSuffix = 'all.mango'
extClass = '.Mango'
extVersionCode = 7
extVersionCode = 8
}
dependencies {

View File

@ -257,7 +257,7 @@ class Mango : ConfigurableSource, HttpSource() {
val loginRequest = POST("$baseUrl/login", formHeaders, formBody)
val response = chain.proceed(loginRequest)
if (response.code != 200 || response.header("Set-Cookie") == null) {
throw Exception("Login Failed. Check Address and Credentials")
throw IOException("Login Failed. Check Address and Credentials")
}
// Save the cookies from the response
apiCookies = response.header("Set-Cookie")!!

View File

@ -5,7 +5,7 @@ ext {
extName = 'AllHentai'
pkgNameSuffix = 'ru.allhentai'
extClass = '.AllHentai'
extVersionCode = 19
extVersionCode = 20
isNsfw = true
}

View File

@ -25,6 +25,7 @@ import org.jsoup.nodes.Element
import rx.Observable
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
import java.io.IOException
import java.text.DecimalFormat
import java.text.ParseException
import java.text.SimpleDateFormat
@ -54,7 +55,7 @@ class AllHentai : ConfigurableSource, ParsedHttpSource() {
val originalRequest = chain.request()
val response = chain.proceed(originalRequest)
if (originalRequest.url.toString().contains(baseUrl) and (originalRequest.url.toString().contains("internal/redirect") or (response.code == 301)))
throw Exception("Манга переехала на другой адрес/ссылку!")
throw IOException("Манга переехала на другой адрес/ссылку!")
response
}
.build()

View File

@ -5,7 +5,7 @@ ext {
extName = 'Mintmanga'
pkgNameSuffix = 'ru.mintmanga'
extClass = '.Mintmanga'
extVersionCode = 42
extVersionCode = 43
}
dependencies {

View File

@ -25,6 +25,7 @@ import org.jsoup.nodes.Element
import rx.Observable
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
import java.io.IOException
import java.text.DecimalFormat
import java.text.ParseException
import java.text.SimpleDateFormat
@ -53,7 +54,7 @@ class Mintmanga : ConfigurableSource, ParsedHttpSource() {
val originalRequest = chain.request()
val response = chain.proceed(originalRequest)
if (originalRequest.url.toString().contains(baseUrl) and (originalRequest.url.toString().contains("internal/redirect") or (response.code == 301)))
throw Exception("Манга переехала на другой адрес/ссылку!")
throw IOException("Манга переехала на другой адрес/ссылку!")
response
}
.build()

View File

@ -5,7 +5,7 @@ ext {
extName = 'Readmanga'
pkgNameSuffix = 'ru.readmanga'
extClass = '.Readmanga'
extVersionCode = 41
extVersionCode = 42
}
dependencies {

View File

@ -25,6 +25,7 @@ import org.jsoup.nodes.Element
import rx.Observable
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
import java.io.IOException
import java.text.DecimalFormat
import java.text.ParseException
import java.text.SimpleDateFormat
@ -53,7 +54,7 @@ class Readmanga : ConfigurableSource, ParsedHttpSource() {
val originalRequest = chain.request()
val response = chain.proceed(originalRequest)
if (originalRequest.url.toString().contains(baseUrl) and (originalRequest.url.toString().contains("internal/redirect") or (response.code == 301)))
throw Exception("Манга переехала на другой адрес/ссылку!")
throw IOException("Манга переехала на другой адрес/ссылку!")
response
}
.build()

View File

@ -5,7 +5,7 @@ ext {
extName = 'Selfmanga'
pkgNameSuffix = 'ru.selfmanga'
extClass = '.Selfmanga'
extVersionCode = 19
extVersionCode = 20
}
dependencies {

View File

@ -15,6 +15,7 @@ import okhttp3.Request
import okhttp3.Response
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
import java.io.IOException
import java.text.DecimalFormat
import java.text.ParseException
import java.text.SimpleDateFormat
@ -39,7 +40,7 @@ class Selfmanga : ParsedHttpSource() {
val originalRequest = chain.request()
val response = chain.proceed(originalRequest)
if (originalRequest.url.toString().contains(baseUrl) and (originalRequest.url.toString().contains("internal/redirect") or (response.code == 301)))
throw Exception("Манга переехала на другой адрес/ссылку!")
throw IOException("Манга переехала на другой адрес/ссылку!")
response
}
.build()