Sha256: ff50fbfa35384c5488e764f58464337fb6da7a81e6fcfe59d9c8edc935712fa3

Contents?: true

Size: 924 Bytes

Versions: 3

Compression:

Stored size: 924 Bytes

Contents

class DripDrop
  class BaseHandler
    
    def on_error(&block)
      @err_cbak = block
    end

    def handle_error(exception,*extra)
      if @err_cbak
        begin
          @err_cbak.call(exception,*extra)
        rescue StandardError => e
          print_exception(e)
        end
      else
        print_exception(e)
      end
    end

    def print_exception(exception)
      $stderr.write exception.message
      $stderr.write exception.backtrace.join("\t\n")
    end
     
    private
    # Normalize Hash objs and DripDrop::Message objs into DripDrop::Message objs
    def dd_messagify(message)
      if message.is_a?(Hash)
        return DripDrop::Message.new(message[:name], :head => message[:head],
                                                     :body => message[:body])
      elsif message.is_a?(DripDrop::Message)
        return message
      else
        return message
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dripdrop-0.9.10 lib/dripdrop/handlers/base.rb
dripdrop-0.9.9 lib/dripdrop/handlers/base.rb
dripdrop-0.9.8 lib/dripdrop/handlers/base.rb