Skip to content

Commit

Permalink
fix error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
moofkit committed May 30, 2024
1 parent b1feeb8 commit 12feed5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ gem "rake", "~> 13.0"
gem "rspec", "~> 3.0"

gem "rubocop", "~> 1.21"
gem "rubocop-performance"
gem "rubocop-rake"
gem "rubocop-rspec"
9 changes: 5 additions & 4 deletions lib/sidekiq/rescue/server_middleware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ def call(job_instance, job_payload, _queue, &block)
private

def sidekiq_rescue(job_payload, job_class)
klasses_to_rescue = job_class.sidekiq_rescue_options.keys.flatten
yield
rescue *klasses_to_rescue => e
error_group, options = job_class.sidekiq_rescue_options.to_a.find do |error_group, _options|
Array(error_group).include?(e.class)
rescue StandardError => e
error_group, options = job_class.sidekiq_rescue_options.reverse_each.find do |error_group, _options|
Array(error_group).any? { |error| e.is_a?(error) }
end
raise e unless error_group

rescue_error(e, error_group, options, job_payload)
end

Expand Down

0 comments on commit 12feed5

Please sign in to comment.