class GorgService::Consumer::MessageHandler::ExceptionManager

Public Class Methods

instance() click to toggle source
# File lib/gorg_service/consumer/message_handler/exception_manager.rb, line 9
def self.instance
  @instance ||= self.new
end

Public Instance Methods

get_rescue_block_for(exception) click to toggle source
# File lib/gorg_service/consumer/message_handler/exception_manager.rb, line 38
def get_rescue_block_for(exception)
  exceptions_hash.find{|k,_v| exception.is_a?(k)}[1]
end
rescuable_exceptions() click to toggle source
# File lib/gorg_service/consumer/message_handler/exception_manager.rb, line 34
def rescuable_exceptions
  exceptions_hash.keys
end
set_rescue_from(*exception_classes,&block) click to toggle source
# File lib/gorg_service/consumer/message_handler/exception_manager.rb, line 28
def set_rescue_from(*exception_classes,&block)
  exception_classes.each do |e|
    exceptions_hash[e]=block
  end
end
with_exception_rescuing(message=nil) { || ... } click to toggle source
# File lib/gorg_service/consumer/message_handler/exception_manager.rb, line 13
def with_exception_rescuing(message=nil)
  begin
    begin
      yield
    rescue *rescuable_exceptions => e
      get_rescue_block_for(e).call(e,message)
    end
  rescue GorgService::Consumer::FailError => e
    raise e
  # rescue StandardError => e
  #   GorgService.logger.error "Uncaught exception : #{e.inspect}"
  #   raise HardfailError.new("UncaughtException", e)
  end
end

Private Instance Methods

exceptions_hash() click to toggle source
# File lib/gorg_service/consumer/message_handler/exception_manager.rb, line 44
def exceptions_hash
  @exceptions_hash ||= Hash.new
end