forked from mastodon/mastodon
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit 'df6086d4027910fb160d531b4fe7ffdec26b0cd7' into glitch-s…
…oc/merge-upstream
- Loading branch information
Showing
40 changed files
with
351 additions
and
244 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# frozen_string_literal: true | ||
|
||
module Api::ErrorHandling | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
rescue_from ActiveRecord::RecordInvalid, Mastodon::ValidationError do |e| | ||
render json: { error: e.to_s }, status: 422 | ||
end | ||
|
||
rescue_from ActiveRecord::RecordNotUnique do | ||
render json: { error: 'Duplicate record' }, status: 422 | ||
end | ||
|
||
rescue_from Date::Error do | ||
render json: { error: 'Invalid date supplied' }, status: 422 | ||
end | ||
|
||
rescue_from ActiveRecord::RecordNotFound do | ||
render json: { error: 'Record not found' }, status: 404 | ||
end | ||
|
||
rescue_from HTTP::Error, Mastodon::UnexpectedResponseError do | ||
render json: { error: 'Remote data could not be fetched' }, status: 503 | ||
end | ||
|
||
rescue_from OpenSSL::SSL::SSLError do | ||
render json: { error: 'Remote SSL certificate could not be verified' }, status: 503 | ||
end | ||
|
||
rescue_from Mastodon::NotPermittedError do | ||
render json: { error: 'This action is not allowed' }, status: 403 | ||
end | ||
|
||
rescue_from Seahorse::Client::NetworkingError do |e| | ||
Rails.logger.warn "Storage server error: #{e}" | ||
render json: { error: 'There was a temporary problem serving your request, please try again' }, status: 503 | ||
end | ||
|
||
rescue_from Mastodon::RaceConditionError, Stoplight::Error::RedLight do | ||
render json: { error: 'There was a temporary problem serving your request, please try again' }, status: 503 | ||
end | ||
|
||
rescue_from Mastodon::RateLimitExceededError do | ||
render json: { error: I18n.t('errors.429') }, status: 429 | ||
end | ||
|
||
rescue_from ActionController::ParameterMissing, Mastodon::InvalidParameterError do |e| | ||
render json: { error: e.to_s }, status: 400 | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.