Rename error classes

This commit is contained in:
Matt Jankowski 2024-10-30 15:46:46 -04:00
parent ed247f3dfc
commit df808b4ebf
13 changed files with 13 additions and 13 deletions

View file

@ -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

View file

@ -196,7 +196,7 @@ module JsonLdHelper
return if compare_id.present? && json['id'] != compare_id
json
rescue Oj::ParseError
rescue JSON::ParserError
nil
end

View file

@ -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

View file

@ -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

View file

@ -78,7 +78,7 @@ class TranslationService::DeepL < TranslationService
provider: 'DeepL.com'
)
end
rescue Oj::ParseError
rescue JSON::ParserError
raise UnexpectedResponseError
end
end

View file

@ -55,7 +55,7 @@ class TranslationService::LibreTranslate < TranslationService
provider: 'LibreTranslate'
)
end
rescue Oj::ParseError
rescue JSON::ParserError
raise UnexpectedResponseError
end
end

View file

@ -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.'

View file

@ -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}"

View file

@ -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

View file

@ -61,7 +61,7 @@ class ActivityPub::ProcessAccountService < BaseService
end
@account
rescue Oj::ParseError
rescue JSON::ParserError
nil
end

View file

@ -38,7 +38,7 @@ class ActivityPub::ProcessCollectionService < BaseService
else
process_items [@json]
end
rescue Oj::ParseError
rescue JSON::ParserError
nil
end

View file

@ -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

View file

@ -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