feat: Show a specific message if requests are rate-limited (#818)

This commit is contained in:
Nik Clayton 2024-07-14 23:43:10 +02:00 committed by GitHub
parent af11e3d3a1
commit b878211891
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 0 deletions

View File

@ -105,6 +105,7 @@ sealed class ClientError(
401 -> Unauthorized(exception) 401 -> Unauthorized(exception)
404 -> NotFound(exception) 404 -> NotFound(exception)
410 -> Gone(exception) 410 -> Gone(exception)
429 -> RateLimit(exception)
else -> UnknownClientError(exception) else -> UnknownClientError(exception)
} }
} }
@ -126,6 +127,10 @@ sealed class ClientError(
data class Gone(override val exception: HttpException) : data class Gone(override val exception: HttpException) :
ClientError(R.string.error_generic_fmt, exception) ClientError(R.string.error_generic_fmt, exception)
/** 429 Rate limit */
data class RateLimit(override val exception: HttpException) :
ClientError(R.string.error_429_rate_limit_fmt, exception)
/** All other 4xx client errors */ /** All other 4xx client errors */
data class UnknownClientError(override val exception: HttpException) : data class UnknownClientError(override val exception: HttpException) :
ClientError(R.string.error_generic_fmt, exception) ClientError(R.string.error_generic_fmt, exception)

View File

@ -23,6 +23,7 @@
<string name="server_error_unparseable_version">could not parse \"%1$s\" as a version: %2$s</string> <string name="server_error_unparseable_version">could not parse \"%1$s\" as a version: %2$s</string>
<string name="error_generic_fmt">An error occurred: %s</string> <string name="error_generic_fmt">An error occurred: %s</string>
<string name="error_404_not_found_fmt">Your server does not support this feature: %1$s</string> <string name="error_404_not_found_fmt">Your server does not support this feature: %1$s</string>
<string name="error_429_rate_limit_fmt">your server is rate-limiting your requests: %1$s</string>
<string name="error_json_data_fmt">Your server returned an invalid response: %1$s</string> <string name="error_json_data_fmt">Your server returned an invalid response: %1$s</string>
<string name="error_network_fmt">A network error occurred: %s</string> <string name="error_network_fmt">A network error occurred: %s</string>
<string name="error_missing_content_type_fmt">your server is mis-configured, the response has no content-type: %1$s</string> <string name="error_missing_content_type_fmt">your server is mis-configured, the response has no content-type: %1$s</string>