@@ -120,25 +120,25 @@ def call(_exception, ctx)
120
120
class Config
121
121
remove_const :ERROR_HANDLER
122
122
123
- ERROR_HANDLER = lambda { | _ex , ctx , _cfg = Sidekiq . default_configuration |
123
+ ERROR_HANDLER = -> ( ex , ctx , cfg = Sidekiq . default_configuration ) do
124
124
unless ctx . empty?
125
125
job_hash = ctx [ :job ] || { }
126
126
klass = job_hash [ "display_class" ] || job_hash [ "wrapped" ] || job_hash [ "class" ]
127
127
logger = klass ? SemanticLogger [ klass ] : Sidekiq . logger
128
128
ctx [ :context ] ? logger . warn ( ctx [ :context ] , ctx ) : logger . warn ( ctx )
129
129
end
130
- }
130
+ end
131
131
end
132
132
else
133
133
# 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
142
142
end
143
143
end
144
144
0 commit comments