Fix Tappytoon crash. (#15148)

This commit is contained in:
Alessandro Jean 2023-01-27 17:07:21 -03:00 committed by GitHub
parent 42720260d1
commit 9675111870
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -6,7 +6,7 @@ ext {
extName = 'Tappytoon' extName = 'Tappytoon'
pkgNameSuffix = 'all.tappytoon' pkgNameSuffix = 'all.tappytoon'
extClass = '.TappytoonFactory' extClass = '.TappytoonFactory'
extVersionCode = 6 extVersionCode = 7
isNsfw = true isNsfw = true
} }

View File

@ -19,6 +19,7 @@ import okhttp3.Request
import okhttp3.Response import okhttp3.Response
import okhttp3.ResponseBody.Companion.toResponseBody import okhttp3.ResponseBody.Companion.toResponseBody
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
@ -45,11 +46,11 @@ class Tappytoon(override val lang: String) : HttpSource() {
// Throw JSON error if available // Throw JSON error if available
if (mime == "application/json") { if (mime == "application/json") {
res.body?.string()?.let(json::parseToJsonElement)?.run { res.body?.string()?.let(json::parseToJsonElement)?.run {
throw Error(jsonObject["message"]!!.jsonPrimitive.content) throw IOException(jsonObject["message"]!!.jsonPrimitive.content)
} }
} }
res.close() res.close()
throw Error("HTTP error ${res.code}") throw IOException("HTTP error ${res.code}")
}.build() }.build()
private val json by injectLazy<Json>() private val json by injectLazy<Json>()