From 0e9c1a297aa15570d87da356f2ac908f1fd433a3 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sat, 17 Sep 2016 17:03:36 +0200 Subject: Improved error handling for FollowRemoteService --- app/services/follow_remote_account_service.rb | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'app/services') 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 -- cgit