Replace Exception with IOException in interceptors to avoid crashes. (#11761)
This commit is contained in:
parent
7d7e3d6f03
commit
9bff18b1fd
|
@ -35,6 +35,7 @@ import rx.schedulers.Schedulers
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
import java.io.IOException
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
@ -298,16 +299,16 @@ abstract class HentaiHand(
|
||||||
val body = jsonObject.toString().toRequestBody(MEDIA_TYPE)
|
val body = jsonObject.toString().toRequestBody(MEDIA_TYPE)
|
||||||
val response = chain.proceed(POST("$baseUrl/api/login", headers, body))
|
val response = chain.proceed(POST("$baseUrl/api/login", headers, body))
|
||||||
if (response.code == 401) {
|
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)
|
if (response.body == null)
|
||||||
throw Exception("Login response body is empty")
|
throw IOException("Login response body is empty")
|
||||||
try {
|
try {
|
||||||
// Returns access token as a string, unless unparseable
|
// Returns access token as a string, unless unparseable
|
||||||
return json.parseToJsonElement(response.body!!.string()).jsonObject["auth"]!!.jsonObject["access-token"]!!.jsonPrimitive.content
|
return json.parseToJsonElement(response.body!!.string()).jsonObject["auth"]!!.jsonObject["access-token"]!!.jsonPrimitive.content
|
||||||
} catch (e: IllegalArgumentException) {
|
} catch (e: IllegalArgumentException) {
|
||||||
throw Exception("Cannot parse login response body")
|
throw IOException("Cannot parse login response body")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ class HentaiHandGenerator : ThemeSourceGenerator {
|
||||||
|
|
||||||
override val themeClass = "HentaiHand"
|
override val themeClass = "HentaiHand"
|
||||||
|
|
||||||
override val baseVersionCode: Int = 1
|
override val baseVersionCode: Int = 2
|
||||||
|
|
||||||
override val sources = listOf(
|
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),
|
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),
|
||||||
|
|
|
@ -6,7 +6,7 @@ ext {
|
||||||
extName = 'Mango'
|
extName = 'Mango'
|
||||||
pkgNameSuffix = 'all.mango'
|
pkgNameSuffix = 'all.mango'
|
||||||
extClass = '.Mango'
|
extClass = '.Mango'
|
||||||
extVersionCode = 7
|
extVersionCode = 8
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
|
@ -257,7 +257,7 @@ class Mango : ConfigurableSource, HttpSource() {
|
||||||
val loginRequest = POST("$baseUrl/login", formHeaders, formBody)
|
val loginRequest = POST("$baseUrl/login", formHeaders, formBody)
|
||||||
val response = chain.proceed(loginRequest)
|
val response = chain.proceed(loginRequest)
|
||||||
if (response.code != 200 || response.header("Set-Cookie") == null) {
|
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
|
// Save the cookies from the response
|
||||||
apiCookies = response.header("Set-Cookie")!!
|
apiCookies = response.header("Set-Cookie")!!
|
||||||
|
|
|
@ -5,7 +5,7 @@ ext {
|
||||||
extName = 'AllHentai'
|
extName = 'AllHentai'
|
||||||
pkgNameSuffix = 'ru.allhentai'
|
pkgNameSuffix = 'ru.allhentai'
|
||||||
extClass = '.AllHentai'
|
extClass = '.AllHentai'
|
||||||
extVersionCode = 19
|
extVersionCode = 20
|
||||||
isNsfw = true
|
isNsfw = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.jsoup.nodes.Element
|
||||||
import rx.Observable
|
import rx.Observable
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
|
import java.io.IOException
|
||||||
import java.text.DecimalFormat
|
import java.text.DecimalFormat
|
||||||
import java.text.ParseException
|
import java.text.ParseException
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
|
@ -54,7 +55,7 @@ class AllHentai : ConfigurableSource, ParsedHttpSource() {
|
||||||
val originalRequest = chain.request()
|
val originalRequest = chain.request()
|
||||||
val response = chain.proceed(originalRequest)
|
val response = chain.proceed(originalRequest)
|
||||||
if (originalRequest.url.toString().contains(baseUrl) and (originalRequest.url.toString().contains("internal/redirect") or (response.code == 301)))
|
if (originalRequest.url.toString().contains(baseUrl) and (originalRequest.url.toString().contains("internal/redirect") or (response.code == 301)))
|
||||||
throw Exception("Манга переехала на другой адрес/ссылку!")
|
throw IOException("Манга переехала на другой адрес/ссылку!")
|
||||||
response
|
response
|
||||||
}
|
}
|
||||||
.build()
|
.build()
|
||||||
|
|
|
@ -5,7 +5,7 @@ ext {
|
||||||
extName = 'Mintmanga'
|
extName = 'Mintmanga'
|
||||||
pkgNameSuffix = 'ru.mintmanga'
|
pkgNameSuffix = 'ru.mintmanga'
|
||||||
extClass = '.Mintmanga'
|
extClass = '.Mintmanga'
|
||||||
extVersionCode = 42
|
extVersionCode = 43
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.jsoup.nodes.Element
|
||||||
import rx.Observable
|
import rx.Observable
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
|
import java.io.IOException
|
||||||
import java.text.DecimalFormat
|
import java.text.DecimalFormat
|
||||||
import java.text.ParseException
|
import java.text.ParseException
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
|
@ -53,7 +54,7 @@ class Mintmanga : ConfigurableSource, ParsedHttpSource() {
|
||||||
val originalRequest = chain.request()
|
val originalRequest = chain.request()
|
||||||
val response = chain.proceed(originalRequest)
|
val response = chain.proceed(originalRequest)
|
||||||
if (originalRequest.url.toString().contains(baseUrl) and (originalRequest.url.toString().contains("internal/redirect") or (response.code == 301)))
|
if (originalRequest.url.toString().contains(baseUrl) and (originalRequest.url.toString().contains("internal/redirect") or (response.code == 301)))
|
||||||
throw Exception("Манга переехала на другой адрес/ссылку!")
|
throw IOException("Манга переехала на другой адрес/ссылку!")
|
||||||
response
|
response
|
||||||
}
|
}
|
||||||
.build()
|
.build()
|
||||||
|
|
|
@ -5,7 +5,7 @@ ext {
|
||||||
extName = 'Readmanga'
|
extName = 'Readmanga'
|
||||||
pkgNameSuffix = 'ru.readmanga'
|
pkgNameSuffix = 'ru.readmanga'
|
||||||
extClass = '.Readmanga'
|
extClass = '.Readmanga'
|
||||||
extVersionCode = 41
|
extVersionCode = 42
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.jsoup.nodes.Element
|
||||||
import rx.Observable
|
import rx.Observable
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
|
import java.io.IOException
|
||||||
import java.text.DecimalFormat
|
import java.text.DecimalFormat
|
||||||
import java.text.ParseException
|
import java.text.ParseException
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
|
@ -53,7 +54,7 @@ class Readmanga : ConfigurableSource, ParsedHttpSource() {
|
||||||
val originalRequest = chain.request()
|
val originalRequest = chain.request()
|
||||||
val response = chain.proceed(originalRequest)
|
val response = chain.proceed(originalRequest)
|
||||||
if (originalRequest.url.toString().contains(baseUrl) and (originalRequest.url.toString().contains("internal/redirect") or (response.code == 301)))
|
if (originalRequest.url.toString().contains(baseUrl) and (originalRequest.url.toString().contains("internal/redirect") or (response.code == 301)))
|
||||||
throw Exception("Манга переехала на другой адрес/ссылку!")
|
throw IOException("Манга переехала на другой адрес/ссылку!")
|
||||||
response
|
response
|
||||||
}
|
}
|
||||||
.build()
|
.build()
|
||||||
|
|
|
@ -5,7 +5,7 @@ ext {
|
||||||
extName = 'Selfmanga'
|
extName = 'Selfmanga'
|
||||||
pkgNameSuffix = 'ru.selfmanga'
|
pkgNameSuffix = 'ru.selfmanga'
|
||||||
extClass = '.Selfmanga'
|
extClass = '.Selfmanga'
|
||||||
extVersionCode = 19
|
extVersionCode = 20
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
|
@ -15,6 +15,7 @@ import okhttp3.Request
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import org.jsoup.nodes.Document
|
import org.jsoup.nodes.Document
|
||||||
import org.jsoup.nodes.Element
|
import org.jsoup.nodes.Element
|
||||||
|
import java.io.IOException
|
||||||
import java.text.DecimalFormat
|
import java.text.DecimalFormat
|
||||||
import java.text.ParseException
|
import java.text.ParseException
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
|
@ -39,7 +40,7 @@ class Selfmanga : ParsedHttpSource() {
|
||||||
val originalRequest = chain.request()
|
val originalRequest = chain.request()
|
||||||
val response = chain.proceed(originalRequest)
|
val response = chain.proceed(originalRequest)
|
||||||
if (originalRequest.url.toString().contains(baseUrl) and (originalRequest.url.toString().contains("internal/redirect") or (response.code == 301)))
|
if (originalRequest.url.toString().contains(baseUrl) and (originalRequest.url.toString().contains("internal/redirect") or (response.code == 301)))
|
||||||
throw Exception("Манга переехала на другой адрес/ссылку!")
|
throw IOException("Манга переехала на другой адрес/ссылку!")
|
||||||
response
|
response
|
||||||
}
|
}
|
||||||
.build()
|
.build()
|
||||||
|
|
Loading…
Reference in New Issue