commit: 994d948c3947b75140c2a2a7de5b81713c7b8ea3
parent: f5e228ad2e2503d7cbe3da975e7d2b473e60712b
Author: Clworld <clworld@ggtea.org>
Date: Thu, 27 Jul 2017 07:38:20 +0900
Add callback_url/acct information for Sidekiq PuSH workers Exception. (#4281)
* Add destination informations to exception on SubscribeWorker and DeliveryWorker.
* Simplify delivery error message.
* Prevent changing Exception type...
* fix typo.
Diffstat:
3 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/app/lib/exceptions.rb b/app/lib/exceptions.rb
@@ -8,11 +8,11 @@ module Mastodon
class UnexpectedResponseError < Error
def initialize(response = nil)
- @response = response
- end
-
- def to_s
- "#{@response.uri} returned code #{@response.code}"
+ if response.respond_to? :uri
+ super("#{response.uri} returned code #{response.code}")
+ else
+ super
+ end
end
end
end
diff --git a/app/workers/pubsubhubbub/delivery_worker.rb b/app/workers/pubsubhubbub/delivery_worker.rb
@@ -16,6 +16,8 @@ class Pubsubhubbub::DeliveryWorker
@subscription = Subscription.find(subscription_id)
@payload = payload
process_delivery unless blocked_domain?
+ rescue => e
+ raise e.class, "Delivery failed for #{subscription&.callback_url}: #{e.message}"
end
private
diff --git a/app/workers/pubsubhubbub/subscribe_worker.rb b/app/workers/pubsubhubbub/subscribe_worker.rb
@@ -22,5 +22,7 @@ class Pubsubhubbub::SubscribeWorker
account = Account.find(account_id)
logger.debug "PuSH re-subscribing to #{account.acct}"
::SubscribeService.new.call(account)
+ rescue => e
+ raise e.class, "Subscribe failed for #{account&.acct}: #{e.message}"
end
end