Sha256: 98b14d44769c29e0ce987d42525791a15bbd79639835a3c41d8e6952f4c716b7
Contents?: true
Size: 1.54 KB
Versions: 1
Compression:
Stored size: 1.54 KB
Contents
module Pwwka module ErrorHandlers # Given a chain of error handlers, calls them until either # one returns false/aborts or we exhaust the chain of handlers class Chain include Pwwka::Logging def initialize(default_handler_chain=[]) @error_handlers = default_handler_chain end def handle_error(message_handler_klass,receiver,queue_name,payload,delivery_info,exception) logf "%{message_handler_klass} has received %{exception}", message_handler_klass: message_handler_klass, exception: exception.message if message_handler_klass.respond_to?(:error_handler) @error_handlers.unshift(message_handler_klass.send(:error_handler)) end @error_handlers.reduce(true) { |keep_going,error_handler| logf "%{error_handler_class} is being evaluated as part of pwwka's error-handling chain", error_handler_class: error_handler if keep_going keep_going = error_handler.new.handle_error(receiver,queue_name,payload,delivery_info,exception) if keep_going logf "%{error_handler_class} has asked to continue pwwka's error-handling chain", error_handler_class: error_handler else logf "%{error_handler_class} has halted pwwka's error-handling chain", error_handler_class: error_handler end else logf "Skipping %{error_handler_class} as we were asked to abort pwwka's error-handling chain", error_handler_class: error_handler end keep_going } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pwwka-0.13.3 | lib/pwwka/error_handlers/chain.rb |