Sha256: 5a4ae7ed85b84108b89a611829f033e4e52cb8cce162712e4a8e912e58b40857

Contents?: true

Size: 573 Bytes

Versions: 2

Compression:

Stored size: 573 Bytes

Contents

module FluQ::Mixins::Logger

  def exception_handlers
    @exception_handlers ||= []
  end

  def exception_handler(&block)
    exception_handlers << block
  end

  def crash(string, exception)
    if exception.respond_to?(:backtrace) && exception.backtrace
      trace = exception.backtrace.map {|line| "  #{line}" }.join("\n")
    end
    error [string, trace].compact.join("\n")

    exception_handlers.each do |handler|
      begin
        handler.call(exception)
      rescue => ex
        error "EXCEPTION HANDLER CRASHED: #{ex.message}"
      end
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fluq-0.7.5 lib/fluq/mixins/logger.rb
fluq-0.7.3 lib/fluq/mixins/logger.rb