Extract wrapper constant for HTTP::*
error classes (#32285)
This commit is contained in:
parent
f49161ab1d
commit
e8ec6667bd
21 changed files with 29 additions and 23 deletions
|
@ -127,13 +127,13 @@ class ActivityPub::ProcessAccountService < BaseService
|
|||
begin
|
||||
@account.avatar_remote_url = image_url('icon') || '' unless skip_download?
|
||||
@account.avatar = nil if @account.avatar_remote_url.blank?
|
||||
rescue Mastodon::UnexpectedResponseError, HTTP::TimeoutError, HTTP::ConnectionError, OpenSSL::SSL::SSLError
|
||||
rescue Mastodon::UnexpectedResponseError, *Mastodon::HTTP_CONNECTION_ERRORS, OpenSSL::SSL::SSLError
|
||||
RedownloadAvatarWorker.perform_in(rand(30..600).seconds, @account.id)
|
||||
end
|
||||
begin
|
||||
@account.header_remote_url = image_url('image') || '' unless skip_download?
|
||||
@account.header = nil if @account.header_remote_url.blank?
|
||||
rescue Mastodon::UnexpectedResponseError, HTTP::TimeoutError, HTTP::ConnectionError, OpenSSL::SSL::SSLError
|
||||
rescue Mastodon::UnexpectedResponseError, *Mastodon::HTTP_CONNECTION_ERRORS, OpenSSL::SSL::SSLError
|
||||
RedownloadHeaderWorker.perform_in(rand(30..600).seconds, @account.id)
|
||||
end
|
||||
@account.statuses_count = outbox_total_items if outbox_total_items.present?
|
||||
|
@ -276,7 +276,7 @@ class ActivityPub::ProcessAccountService < BaseService
|
|||
total_items = collection.is_a?(Hash) && collection['totalItems'].present? && collection['totalItems'].is_a?(Numeric) ? collection['totalItems'] : nil
|
||||
has_first_page = collection.is_a?(Hash) && collection['first'].present?
|
||||
@collections[type] = [total_items, has_first_page]
|
||||
rescue HTTP::Error, OpenSSL::SSL::SSLError, Mastodon::LengthValidationError
|
||||
rescue *Mastodon::HTTP_CONNECTION_ERRORS, OpenSSL::SSL::SSLError, Mastodon::LengthValidationError
|
||||
@collections[type] = [nil, nil]
|
||||
end
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
|
|||
media_attachment.download_file! if media_attachment.remote_url_previously_changed?
|
||||
media_attachment.download_thumbnail! if media_attachment.thumbnail_remote_url_previously_changed?
|
||||
media_attachment.save
|
||||
rescue Mastodon::UnexpectedResponseError, HTTP::TimeoutError, HTTP::ConnectionError, OpenSSL::SSL::SSLError
|
||||
rescue Mastodon::UnexpectedResponseError, *Mastodon::HTTP_CONNECTION_ERRORS, OpenSSL::SSL::SSLError
|
||||
RedownloadMediaWorker.perform_in(rand(30..600).seconds, media_attachment.id)
|
||||
rescue Seahorse::Client::NetworkingError => e
|
||||
Rails.logger.warn "Error storing media attachment: #{e}"
|
||||
|
|
|
@ -29,7 +29,7 @@ class FetchLinkCardService < BaseService
|
|||
end
|
||||
|
||||
attach_card if @card&.persisted?
|
||||
rescue HTTP::Error, OpenSSL::SSL::SSLError, Addressable::URI::InvalidURIError, Mastodon::HostValidationError, Mastodon::LengthValidationError, Encoding::UndefinedConversionError, ActiveRecord::RecordInvalid => e
|
||||
rescue *Mastodon::HTTP_CONNECTION_ERRORS, OpenSSL::SSL::SSLError, Addressable::URI::InvalidURIError, Mastodon::HostValidationError, Mastodon::LengthValidationError, Encoding::UndefinedConversionError, ActiveRecord::RecordInvalid => e
|
||||
Rails.logger.debug { "Error fetching link #{@original_url}: #{e}" }
|
||||
nil
|
||||
end
|
||||
|
|
|
@ -12,7 +12,7 @@ class FetchResourceService < BaseService
|
|||
return if url.blank?
|
||||
|
||||
process(url)
|
||||
rescue HTTP::Error, OpenSSL::SSL::SSLError, Addressable::URI::InvalidURIError, Mastodon::HostValidationError, Mastodon::LengthValidationError => e
|
||||
rescue *Mastodon::HTTP_CONNECTION_ERRORS, OpenSSL::SSL::SSLError, Addressable::URI::InvalidURIError, Mastodon::HostValidationError, Mastodon::LengthValidationError => e
|
||||
Rails.logger.debug { "Error fetching resource #{@url}: #{e}" }
|
||||
nil
|
||||
end
|
||||
|
|
|
@ -115,7 +115,7 @@ class ImportService < BaseService
|
|||
next if status.nil? && ActivityPub::TagManager.instance.local_uri?(uri)
|
||||
|
||||
status || ActivityPub::FetchRemoteStatusService.new.call(uri)
|
||||
rescue HTTP::Error, OpenSSL::SSL::SSLError, Mastodon::UnexpectedResponseError
|
||||
rescue *Mastodon::HTTP_CONNECTION_ERRORS, OpenSSL::SSL::SSLError, Mastodon::UnexpectedResponseError
|
||||
nil
|
||||
rescue => e
|
||||
Rails.logger.warn "Unexpected error when importing bookmark: #{e}"
|
||||
|
|
|
@ -44,7 +44,7 @@ class ProcessMentionsService < BaseService
|
|||
if mention_undeliverable?(mentioned_account)
|
||||
begin
|
||||
mentioned_account = ResolveAccountService.new.call(Regexp.last_match(1))
|
||||
rescue Webfinger::Error, HTTP::Error, OpenSSL::SSL::SSLError, Mastodon::UnexpectedResponseError
|
||||
rescue Webfinger::Error, *Mastodon::HTTP_CONNECTION_ERRORS, OpenSSL::SSL::SSLError, Mastodon::UnexpectedResponseError
|
||||
mentioned_account = nil
|
||||
end
|
||||
end
|
||||
|
|
|
@ -22,7 +22,7 @@ class SoftwareUpdateCheckService < BaseService
|
|||
Request.new(:get, "#{api_url}?version=#{version}").add_headers('Accept' => 'application/json', 'User-Agent' => 'Mastodon update checker').perform do |res|
|
||||
return Oj.load(res.body_with_limit, mode: :strict) if res.code == 200
|
||||
end
|
||||
rescue HTTP::Error, OpenSSL::SSL::SSLError, Oj::ParseError
|
||||
rescue *Mastodon::HTTP_CONNECTION_ERRORS, OpenSSL::SSL::SSLError, Oj::ParseError
|
||||
nil
|
||||
end
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ class VerifyLinkService < BaseService
|
|||
return unless link_back_present?
|
||||
|
||||
field.mark_verified!
|
||||
rescue OpenSSL::SSL::SSLError, HTTP::Error, Addressable::URI::InvalidURIError, Mastodon::HostValidationError, Mastodon::LengthValidationError, IPAddr::AddressFamilyError => e
|
||||
rescue OpenSSL::SSL::SSLError, *Mastodon::HTTP_CONNECTION_ERRORS, Addressable::URI::InvalidURIError, Mastodon::HostValidationError, Mastodon::LengthValidationError, IPAddr::AddressFamilyError => e
|
||||
Rails.logger.debug { "Error fetching link #{@url}: #{e}" }
|
||||
nil
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue