Class: SidekiqMiddlewares::CleanAndShortBacktraces

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq_middlewares.rb

Instance Method Summary collapse

Instance Method Details

#call(worker, item, queue) ⇒ Object


3
4
5
6
7
8
9
10
11
12
# File 'lib/sidekiq_middlewares.rb', line 3

def call(worker, item, queue)
  yield
rescue Exception
  backtrace = Rails.backtrace_cleaner.clean($!.backtrace)
  backtrace.reject! { |line| line =~ /lib\/sidekiq_middlewares.rb/ }
  limit = AppConfig.environment.sidekiq.backtrace.get
  limit = limit ? limit.to_i : 0
  backtrace = [] if limit == 0
  raise $!, $!.message, backtrace[0..limit]
end