diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2016-09-17 17:03:36 +0200 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2016-09-17 17:03:36 +0200 |
commit | 0e9c1a297aa15570d87da356f2ac908f1fd433a3 (patch) | |
tree | 1c8ab8e3115f6890229fe34a41e5c827d7dd1679 /app/services | |
parent | 8c0b19012bae203f41b75cf40d6baf121f67fdea (diff) |
Improved error handling for FollowRemoteService
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/follow_remote_account_service.rb | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/app/services/follow_remote_account_service.rb b/app/services/follow_remote_account_service.rb index 0e23ed7d2..00285f47a 100644 --- a/app/services/follow_remote_account_service.rb +++ b/app/services/follow_remote_account_service.rb @@ -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 |