Skip to content

Commit

Permalink
Merge pull request #184 from nikz/fix-sidekiq-error-handler-api-change
Browse files Browse the repository at this point in the history
Fixes backward incompatible Sidekiq change
  • Loading branch information
nikz committed Jun 1, 2024
2 parents c029c6e + 18593c9 commit 0da2d2f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/raygun/sidekiq.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
module Raygun

class SidekiqReporter
def self.call(exception, context_hash, config)
def self.call(exception, context_hash = {}, config = nil)
user = affected_user(context_hash)
data = {
custom_data: {
Expand Down
11 changes: 11 additions & 0 deletions test/unit/sidekiq_failure_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ def test_failure_backend_appears_to_work
assert response && response.success?, "Expected success, got #{response.class}: #{response.inspect}"
end

# See https://github.com/MindscapeHQ/raygun4ruby/issues/183
# (This is how Sidekiq pre 7.1.5 calls error handlers: https://github.com/sidekiq/sidekiq/blob/1ba89bbb22d2fd574b11702d8b6ed63ae59e2256/lib/sidekiq/config.rb#L269)
def test_failure_backend_appears_to_work_without_config_argument
response = Raygun::SidekiqReporter.call(
StandardError.new("Oh no! Your Sidekiq has failed!"),
{ sidekick_name: "robin" }
)

assert response && response.success?, "Expected success, got #{response.class}: #{response.inspect}"
end

def test_we_are_in_sidekiqs_list_of_error_handlers
# Sidekiq 7.x stores error handlers inside a configuration object, while 6.x and below stores them directly against the Sidekiq module
error_handlers = Sidekiq.respond_to?(:error_handlers) ? Sidekiq.error_handlers : Sidekiq.default_configuration.error_handlers
Expand Down

0 comments on commit 0da2d2f

Please sign in to comment.