fix: code cleanup | reply/edit stability

This commit is contained in:
rebelonion 2024-02-21 22:59:45 -06:00
parent a74b9e985d
commit ba7c665a9d
3 changed files with 336 additions and 353 deletions

View file

@ -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")