Class: CronoTrigger::GlobalExceptionHandler

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.handle_global_exception(ex) ⇒ Object



3
4
5
# File 'lib/crono_trigger/global_exception_handler.rb', line 3

def self.handle_global_exception(ex)
  new.handle_global_exception(ex)
end

Instance Method Details

#handle_global_exception(ex) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/crono_trigger/global_exception_handler.rb', line 7

def handle_global_exception(ex)
  handlers = CronoTrigger.config.global_error_handlers
  handlers.each do |callable|
    callable, arity = ensure_callable(callable)

    args = [ex]
    args = arity < 0 ? args : args.take(arity)
    callable.call(*args)
  end
rescue Exception => e
  ActiveRecord::Base.logger.error("CronoTrigger error handler raises error")
  ActiveRecord::Base.logger.error(e)
end