Sha256: cfebd461711066ad25a01509c6308c5a6da8e72ba2fd23a009732d188a4429af

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents

module Blather
  # Main error class
  class BlatherError < StandardError
    class_inheritable_array :handler_heirarchy

    self.handler_heirarchy ||= []
    self.handler_heirarchy << :error

    def self.register(handler)
      self.handler_heirarchy.unshift handler
    end
  end

  ##
  # Used in cases where a stanza only allows specific values for its attributes
  # and an invalid value is attempted.
  class ArgumentError < BlatherError
    register :argument_error
  end

  ##
  # The stream handler received a response it didn't know how to handle
  class UnknownResponse < BlatherError
    register :unknown_response_error
    attr_reader :node

    def initialize(node)
      @node = node
    end
  end

  ##
  # TLS negotiations broke down
  class TLSFailure < BlatherError
    register :tls_failure
  end

  ##
  # Something bad happened while parsing the incoming stream
  class ParseError < BlatherError
    register :parse_error
    attr_reader :message

    def initialize(message)
      @message = message
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
sprsquish-blather-0.2.3 lib/blather/errors.rb
blather-0.2.2 lib/blather/errors.rb
blather-0.2.3 lib/blather/errors.rb