Skip to content

Add callback_url/acct information for Sidekiq PuSH workers Exception(alternative)#4283

Closed
clworld wants to merge 3 commits intomastodon:masterfrom
clworld:add_destinfo_to_sidekiq_error2
Closed

Add callback_url/acct information for Sidekiq PuSH workers Exception(alternative)#4283
clworld wants to merge 3 commits intomastodon:masterfrom
clworld:add_destinfo_to_sidekiq_error2

Conversation

@clworld
Copy link
Copy Markdown
Contributor

@clworld clworld commented Jul 20, 2017

This is alternative implementation of #4281.
sidekiq_fixx

end
end
rescue HTTP::Error, OStatus2::BadSalmonError, Mastodon::NotPermittedError
rescue HTTP::Error, OStatus2::BadSalmonError, Mastodon::NotPermittedError, Mastodon::WorkerError
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's for deal with rspec error. WorkerError will be raised from inside of perform_async only when test.

@payload = payload
process_delivery unless blocked_domain?
rescue => e
raise Mastodon::WorkerError, "Delivery failed for #{subscription&.callback_url}: #{e.class}: #{e.message}"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrap exception for adding callback_url to exception message.

logger.debug "PuSH re-subscribing to #{account.acct}"
::SubscribeService.new.call(account)
rescue => e
raise Mastodon::WorkerError, "Subscribe failed for #{account&.acct}: #{e.class}: #{e.message}"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrap exception for adding acct to exception message.

rescue Mastodon::WorkerError => e
e.cause
end
).to be_an(ActiveRecord::RecordNotFound)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is better way to write test to check e.cause... but I didn't found it..

Comment thread app/lib/exceptions.rb
class NotPermittedError < Error; end
class ValidationError < Error; end
class RaceConditionError < Error; end
class WorkerError < Error; end
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add exception for wrap exception in Sidekiq worker. (wrapped exceptions are raised to Sidekiq)

@beatrix-bitrot
Copy link
Copy Markdown
Contributor

I like it but I kind of want to know @Gargron thoughts on the matter since he recently changed some exception handling stuff

@beatrix-bitrot beatrix-bitrot requested a review from Gargron July 21, 2017 04:14
@Gargron
Copy link
Copy Markdown
Member

Gargron commented Jul 26, 2017

I chose the other PR for simplicity.

@Gargron Gargron closed this Jul 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants