mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-25 07:05:20 +00:00
Rename error classes
This commit is contained in:
parent
ed247f3dfc
commit
df808b4ebf
|
@ -23,7 +23,7 @@ class ActivityPub::InboxesController < ActivityPub::BaseController
|
|||
def unknown_affected_account?
|
||||
json = JSON.parse(body)
|
||||
json.is_a?(Hash) && %w(Delete Update).include?(json['type']) && json['actor'].present? && json['actor'] == value_or_id(json['object']) && !Account.exists?(uri: json['actor'])
|
||||
rescue Oj::ParseError
|
||||
rescue JSON::ParserError
|
||||
false
|
||||
end
|
||||
|
||||
|
|
|
@ -196,7 +196,7 @@ module JsonLdHelper
|
|||
return if compare_id.present? && json['id'] != compare_id
|
||||
|
||||
json
|
||||
rescue Oj::ParseError
|
||||
rescue JSON::ParserError
|
||||
nil
|
||||
end
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ class Admin::Metrics::Dimension::SoftwareVersionsDimension < Admin::Metrics::Dim
|
|||
value: version,
|
||||
human_value: version,
|
||||
}
|
||||
rescue Terrapin::CommandNotFoundError, Terrapin::ExitStatusError, Oj::ParseError
|
||||
rescue Terrapin::CommandNotFoundError, Terrapin::ExitStatusError, JSON::ParserError
|
||||
nil
|
||||
end
|
||||
|
||||
|
|
|
@ -263,7 +263,7 @@ class LinkDetailsExtractor
|
|||
next unless structured_data.valid?
|
||||
|
||||
structured_data
|
||||
rescue Oj::ParseError, EncodingError
|
||||
rescue JSON::ParserError, EncodingError
|
||||
Rails.logger.debug { "Invalid JSON-LD in #{@original_url}" }
|
||||
next
|
||||
end.first
|
||||
|
|
|
@ -78,7 +78,7 @@ class TranslationService::DeepL < TranslationService
|
|||
provider: 'DeepL.com'
|
||||
)
|
||||
end
|
||||
rescue Oj::ParseError
|
||||
rescue JSON::ParserError
|
||||
raise UnexpectedResponseError
|
||||
end
|
||||
end
|
||||
|
|
|
@ -55,7 +55,7 @@ class TranslationService::LibreTranslate < TranslationService
|
|||
provider: 'LibreTranslate'
|
||||
)
|
||||
end
|
||||
rescue Oj::ParseError
|
||||
rescue JSON::ParserError
|
||||
raise UnexpectedResponseError
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,7 +9,7 @@ class VideoMetadataExtractor
|
|||
@metadata = JSON.parse(ffmpeg_command_output, symbolize_names: true)
|
||||
|
||||
parse_metadata
|
||||
rescue Terrapin::ExitStatusError, Oj::ParseError
|
||||
rescue Terrapin::ExitStatusError, JSON::ParserError
|
||||
@invalid = true
|
||||
rescue Terrapin::CommandNotFoundError
|
||||
raise Paperclip::Errors::CommandNotFoundError, 'Could not run the `ffprobe` command. Please install ffmpeg.'
|
||||
|
|
|
@ -57,7 +57,7 @@ class Webfinger
|
|||
|
||||
def perform
|
||||
Response.new(@uri, body_from_webfinger)
|
||||
rescue Oj::ParseError
|
||||
rescue JSON::ParserError
|
||||
raise Webfinger::Error, "Invalid JSON in response for #{@uri}"
|
||||
rescue Addressable::URI::InvalidURIError
|
||||
raise Webfinger::Error, "Invalid URI for #{@uri}"
|
||||
|
|
|
@ -19,7 +19,7 @@ class ActivityPub::FetchRemoteActorService < BaseService
|
|||
else
|
||||
body_to_json(prefetched_body, compare_id: uri)
|
||||
end
|
||||
rescue Oj::ParseError
|
||||
rescue JSON::ParserError
|
||||
raise Error, "Error parsing JSON-LD document #{uri}"
|
||||
end
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ class ActivityPub::ProcessAccountService < BaseService
|
|||
end
|
||||
|
||||
@account
|
||||
rescue Oj::ParseError
|
||||
rescue JSON::ParserError
|
||||
nil
|
||||
end
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ class ActivityPub::ProcessCollectionService < BaseService
|
|||
else
|
||||
process_items [@json]
|
||||
end
|
||||
rescue Oj::ParseError
|
||||
rescue JSON::ParserError
|
||||
nil
|
||||
end
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ class FetchOEmbedService
|
|||
end
|
||||
|
||||
validate(parse_for_format(body)) if body.present?
|
||||
rescue Oj::ParseError, Ox::ParseError
|
||||
rescue JSON::ParserError, Ox::ParseError
|
||||
nil
|
||||
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 JSON.parse(res.body_with_limit) if res.code == 200
|
||||
end
|
||||
rescue *Mastodon::HTTP_CONNECTION_ERRORS, Oj::ParseError
|
||||
rescue *Mastodon::HTTP_CONNECTION_ERRORS, JSON::ParserError
|
||||
nil
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue