mirror of
https://github.com/rebelonion/Dantotsu.git
synced 2026-01-21 05:03:56 +00:00
fix: crash on comments api connection failure
This commit is contained in:
@@ -17,6 +17,7 @@ import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
import kotlinx.serialization.json.Json
|
||||
import okhttp3.FormBody
|
||||
import okio.IOException
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
@@ -159,7 +160,12 @@ object CommentsAPI {
|
||||
.add("token", token)
|
||||
.build()
|
||||
val request = requestBuilder()
|
||||
val json = request.post(url, requestBody = body)
|
||||
val json = try {
|
||||
request.post(url, requestBody = body)
|
||||
} catch (e: IOException) {
|
||||
snackString("Failed to login to comments API")
|
||||
return
|
||||
}
|
||||
if (!json.text.startsWith("{")) return
|
||||
val parsed = try {
|
||||
Json.decodeFromString<AuthResponse>(json.text)
|
||||
|
||||
@@ -34,8 +34,8 @@ class NetworkHelper(
|
||||
maxSize = 5L * 1024 * 1024, // 5 MiB
|
||||
),
|
||||
)
|
||||
.addInterceptor(BrotliInterceptor)
|
||||
.addInterceptor(UncaughtExceptionInterceptor())
|
||||
.addInterceptor(BrotliInterceptor)
|
||||
.addInterceptor(UserAgentInterceptor(::defaultUserAgentProvider))
|
||||
|
||||
if (PrefManager.getVal(PrefName.VerboseLogging)) {
|
||||
|
||||
Reference in New Issue
Block a user