diff --git a/CHANGELOG.md b/CHANGELOG.md index 52a16ec6..10a76ff8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,9 @@ adheres to [Semantic Versioning](http://semver.org/). ### Fixed - `Honeybadger::Config#respond_to?` would always return true (#490) +### Changed +- Accept three arguments for the Sidekiq error handler (#495) + ## [5.2.1] - 2023-03-14 ### Fixed - Remove ANSI escape codes from detailed error message in Ruby 3.2 (#473) diff --git a/lib/honeybadger/plugins/sidekiq.rb b/lib/honeybadger/plugins/sidekiq.rb index b5a03042..eae907b1 100644 --- a/lib/honeybadger/plugins/sidekiq.rb +++ b/lib/honeybadger/plugins/sidekiq.rb @@ -24,10 +24,17 @@ def call(_worker, _msg, _queue) if defined?(::Sidekiq::VERSION) && ::Sidekiq::VERSION > '3' ::Sidekiq.configure_server do |sidekiq| - sidekiq.error_handlers << lambda { |ex, sidekiq_params| + sidekiq_default_configuration = (::Sidekiq::VERSION > '7') ? + ::Sidekiq.default_configuration : Class.new + + sidekiq.error_handlers << lambda { |ex, sidekiq_params, sidekiq_config = sidekiq_default_configuration| params = sidekiq_params.dup - if defined?(::Sidekiq::Config) && params[:_config].is_a?(::Sidekiq::Config) - params[:_config] = params[:_config].instance_variable_get(:@options) + if defined?(::Sidekiq::Config) + if params[:_config].is_a?(::Sidekiq::Config) # Sidekiq > 6 and < 7.1.5 + params[:_config] = params[:_config].instance_variable_get(:@options) + else # Sidekiq >= 7.1.5 + params[:_config] = sidekiq_config.instance_variable_get(:@options) + end end job = params[:job] || params diff --git a/spec/unit/honeybadger/plugins/sidekiq_spec.rb b/spec/unit/honeybadger/plugins/sidekiq_spec.rb index 6fe785ee..57a5a5db 100644 --- a/spec/unit/honeybadger/plugins/sidekiq_spec.rb +++ b/spec/unit/honeybadger/plugins/sidekiq_spec.rb @@ -19,6 +19,9 @@ Class.new do def self.configure_server end + + def self.default_configuration + end end end