Improve error messages when DeepL quota is exceeded (#26704)

This commit is contained in:
Lukas Martini 2023-08-29 09:14:44 +02:00 committed by GitHub
parent 10b06436d1
commit a7d96e6aff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View file

@ -8,7 +8,15 @@ class Api::V1::Statuses::TranslationsController < Api::BaseController
before_action :set_translation before_action :set_translation
rescue_from TranslationService::NotConfiguredError, with: :not_found rescue_from TranslationService::NotConfiguredError, with: :not_found
rescue_from TranslationService::UnexpectedResponseError, TranslationService::QuotaExceededError, TranslationService::TooManyRequestsError, with: :service_unavailable rescue_from TranslationService::UnexpectedResponseError, with: :service_unavailable
rescue_from TranslationService::QuotaExceededError do
render json: { error: I18n.t('translation.errors.quota_exceeded') }, status: 503
end
rescue_from TranslationService::TooManyRequestsError do
render json: { error: I18n.t('translation.errors.too_many_requests') }, status: 503
end
def create def create
render json: @translation, serializer: REST::TranslationSerializer render json: @translation, serializer: REST::TranslationSerializer

View file

@ -1709,6 +1709,10 @@ en:
default: "%b %d, %Y, %H:%M" default: "%b %d, %Y, %H:%M"
month: "%b %Y" month: "%b %Y"
time: "%H:%M" time: "%H:%M"
translation:
errors:
quota_exceeded: The server-wide usage quota for the translation service has been exceeded.
too_many_requests: There have been too many requests to the translation service recently.
two_factor_authentication: two_factor_authentication:
add: Add add: Add
disable: Disable 2FA disable: Disable 2FA