fix: code cleanup | reply/edit stability
This commit is contained in:
parent
a74b9e985d
commit
ba7c665a9d
3 changed files with 336 additions and 353 deletions
|
@ -194,10 +194,23 @@ object CommentsAPI {
|
|||
429 -> "Rate limited. :("
|
||||
else -> "Failed to connect"
|
||||
}
|
||||
snackString("Error $code: ${reason ?: error}")
|
||||
val parsed = try {
|
||||
Json.decodeFromString<ErrorResponse>(reason!!)
|
||||
} catch (e: Exception) {
|
||||
null
|
||||
}
|
||||
val message = parsed?.message ?: reason ?: error
|
||||
|
||||
snackString("Error $code: $message")
|
||||
}
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class ErrorResponse(
|
||||
@SerialName("message")
|
||||
val message: String
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class AuthResponse(
|
||||
@SerialName("authToken")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue