Sha256: 4acdb1925ec87541610ddb65428cf7f186ea6f02f59eff329fb3cccca7c70a9f
Contents?: true
Size: 901 Bytes
Versions: 21
Compression:
Stored size: 901 Bytes
Contents
module CronoTrigger class ExceptionHandler def self.handle_exception(record, ex) new(record).handle_exception(ex) end def initialize(record) @record = record end def handle_exception(ex) handlers = CronoTrigger.config.error_handlers + Array(@record.crono_trigger_options[: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 private def ensure_callable(callable) if callable.respond_to?(:call) return callable, callable.arity elsif callable.is_a?(Symbol) return @record.method(callable), 1 end end end end
Version data entries
21 entries across 21 versions & 1 rubygems