fix: tiny autumn improvements
Signed-off-by: Infi <infi@infi.sh>
This commit is contained in:
parent
1661975a94
commit
be019e7445
|
|
@ -381,5 +381,7 @@ data class RateLimitResponse(@SerialName("retry_after") val retryAfter: Int) {
|
|||
}
|
||||
}
|
||||
|
||||
class HitRateLimitException(retryAfter: Int) :
|
||||
Exception("Hit rate limit, retry after ${retryAfter}ms")
|
||||
internal const val NO_RETRY_AFTER = Int.MIN_VALUE
|
||||
|
||||
class HitRateLimitException(retryAfter: Int = NO_RETRY_AFTER) :
|
||||
Exception(if (retryAfter == NO_RETRY_AFTER) "Hit rate limit" else "Hit rate limit, retry after ${retryAfter}ms")
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package chat.revolt.api.routes.microservices.autumn
|
||||
|
||||
import chat.revolt.api.HitRateLimitException
|
||||
import chat.revolt.api.REVOLT_FILES
|
||||
import chat.revolt.api.RevoltAPI
|
||||
import chat.revolt.api.RevoltHttp
|
||||
|
|
@ -67,7 +68,7 @@ suspend fun uploadToAutumn(
|
|||
throw Exception(error.type)
|
||||
} catch (e: Exception) {
|
||||
if (response.status == HttpStatusCode.TooManyRequests) {
|
||||
throw Exception("Rate limited")
|
||||
throw HitRateLimitException()
|
||||
}
|
||||
if (response.status == HttpStatusCode.PayloadTooLarge) {
|
||||
throw Exception("File too large")
|
||||
|
|
|
|||
Loading…
Reference in New Issue