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.
This commit is contained in:
Clworld 2017-07-27 07:38:20 +09:00 committed by Eugen Rochko
parent f5e228ad2e
commit 994d948c39
3 changed files with 9 additions and 5 deletions

View file

@ -8,11 +8,11 @@ module Mastodon
class UnexpectedResponseError < Error class UnexpectedResponseError < Error
def initialize(response = nil) def initialize(response = nil)
@response = response if response.respond_to? :uri
end super("#{response.uri} returned code #{response.code}")
else
def to_s super
"#{@response.uri} returned code #{@response.code}" end
end end
end end
end end

View file

@ -16,6 +16,8 @@ class Pubsubhubbub::DeliveryWorker
@subscription = Subscription.find(subscription_id) @subscription = Subscription.find(subscription_id)
@payload = payload @payload = payload
process_delivery unless blocked_domain? process_delivery unless blocked_domain?
rescue => e
raise e.class, "Delivery failed for #{subscription&.callback_url}: #{e.message}"
end end
private private

View file

@ -22,5 +22,7 @@ class Pubsubhubbub::SubscribeWorker
account = Account.find(account_id) account = Account.find(account_id)
logger.debug "PuSH re-subscribing to #{account.acct}" logger.debug "PuSH re-subscribing to #{account.acct}"
::SubscribeService.new.call(account) ::SubscribeService.new.call(account)
rescue => e
raise e.class, "Subscribe failed for #{account&.acct}: #{e.message}"
end end
end end