Class: CronoTrigger::ExceptionHandler
- Inherits:
-
Object
- Object
- CronoTrigger::ExceptionHandler
- Defined in:
- lib/crono_trigger/exception_handler.rb
Class Method Summary collapse
Instance Method Summary collapse
- #handle_exception(ex) ⇒ Object
-
#initialize(record) ⇒ ExceptionHandler
constructor
A new instance of ExceptionHandler.
Constructor Details
#initialize(record) ⇒ ExceptionHandler
Returns a new instance of ExceptionHandler.
7 8 9 |
# File 'lib/crono_trigger/exception_handler.rb', line 7 def initialize(record) @record = record end |
Class Method Details
.handle_exception(record, ex) ⇒ Object
3 4 5 |
# File 'lib/crono_trigger/exception_handler.rb', line 3 def self.handle_exception(record, ex) new(record).handle_exception(ex) end |
Instance Method Details
#handle_exception(ex) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/crono_trigger/exception_handler.rb', line 11 def handle_exception(ex) handlers = CronoTrigger.config.error_handlers + Array(@record.[:error_handlers]) handlers.each do |callable| callable, arity = ensure_callable(callable) args = [ex, @record] args = arity < 0 ? args : args.take(arity) callable.call(*args) end rescue Exception => e @record.logger.error("CronoTrigger error handler raises error") @record.logger.error(e) end |