@@ -120,25 +120,25 @@ def call(_exception, ctx)
120120 class Config
121121 remove_const :ERROR_HANDLER
122122
123- ERROR_HANDLER = lambda { | _ex , ctx , _cfg = Sidekiq . default_configuration |
123+ ERROR_HANDLER = -> ( ex , ctx , cfg = Sidekiq . default_configuration ) do
124124 unless ctx . empty?
125125 job_hash = ctx [ :job ] || { }
126126 klass = job_hash [ "display_class" ] || job_hash [ "wrapped" ] || job_hash [ "class" ]
127127 logger = klass ? SemanticLogger [ klass ] : Sidekiq . logger
128128 ctx [ :context ] ? logger . warn ( ctx [ :context ] , ctx ) : logger . warn ( ctx )
129129 end
130- }
130+ end
131131 end
132132 else
133133 # Sidekiq >= 6.5
134- # TODO: Not taking effect. See test/sidekiq_test.rb
135- def self . default_error_handler ( _exception , ctx )
136- return if ctx . empty?
137-
138- job_hash = ctx [ :job ] || { }
139- klass = job_hash [ "display_class" ] || job_hash [ "wrapped" ] || job_hash [ "class" ]
140- logger = klass ? SemanticLogger [ klass ] : Sidekiq . logger
141- ctx [ :context ] ? logger . warn ( ctx [ :context ] , ctx ) : logger . warn ( ctx )
134+ Sidekiq . error_handlers . delete ( Sidekiq :: DEFAULT_ERROR_HANDLER )
135+ Sidekiq . error_handlers << -> ( ex , ctx ) do
136+ unless ctx . empty?
137+ job_hash = ctx [ :job ] || { }
138+ klass = job_hash [ "display_class" ] || job_hash [ "wrapped" ] || job_hash [ "class" ]
139+ logger = klass ? SemanticLogger [ klass ] : Sidekiq . logger
140+ ctx [ :context ] ? logger . warn ( ctx [ :context ] , ctx ) : logger . warn ( ctx )
141+ end
142142 end
143143 end
144144
0 commit comments