Improved error handling for FollowRemoteService
This commit is contained in:
parent
8c0b19012b
commit
0e9c1a297a
3 changed files with 29 additions and 11 deletions
|
@ -31,9 +31,12 @@ class FollowRemoteAccountService < BaseService
|
|||
feed = get_feed(account.remote_url)
|
||||
hubs = feed.xpath('//xmlns:link[@rel="hub"]')
|
||||
|
||||
if hubs.empty? || hubs.first.attribute('href').nil? || feed.at_xpath('/xmlns:feed/xmlns:author/xmlns:uri').nil?
|
||||
Rails.logger.debug "Cannot find PuSH hub or author for #{uri}"
|
||||
return nil
|
||||
if hubs.empty? || hubs.first.attribute('href').nil?
|
||||
raise Goldfinger::Error, "No PubSubHubbub hubs found"
|
||||
end
|
||||
|
||||
if feed.at_xpath('/xmlns:feed/xmlns:author/xmlns:uri').nil?
|
||||
raise Goldfinger::Error, "No author URI found"
|
||||
end
|
||||
|
||||
account.uri = feed.at_xpath('/xmlns:feed/xmlns:author/xmlns:uri').content
|
||||
|
@ -53,9 +56,6 @@ class FollowRemoteAccountService < BaseService
|
|||
end
|
||||
|
||||
return account
|
||||
rescue Goldfinger::Error, HTTP::Error
|
||||
Rails.logger.debug "Error while fetching data for #{uri}"
|
||||
nil
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -89,3 +89,9 @@ class FollowRemoteAccountService < BaseService
|
|||
HTTP
|
||||
end
|
||||
end
|
||||
|
||||
class NoAuthorFeedError < StandardError
|
||||
end
|
||||
|
||||
class NoHubError < StandardError
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue