about summary refs log tree commit diff
path: root/app/services
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-09-17 17:03:36 +0200
committerEugen Rochko <eugen@zeonfederated.com>2016-09-17 17:03:36 +0200
commit0e9c1a297aa15570d87da356f2ac908f1fd433a3 (patch)
tree1c8ab8e3115f6890229fe34a41e5c827d7dd1679 /app/services
parent8c0b19012bae203f41b75cf40d6baf121f67fdea (diff)
Improved error handling for FollowRemoteService
Diffstat (limited to 'app/services')
-rw-r--r--app/services/follow_remote_account_service.rb18
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