Sha256: aead1633aac920383ec62443a2a3f2c04e033f21a08f080676f40a6431a3c36f

Contents?: true

Size: 1.56 KB

Versions: 34

Compression:

Stored size: 1.56 KB

Contents

module Blather
  # Main error class
  # This starts the error hierarchy
  #
  # @handler :error
  class BlatherError < StandardError
    class_attribute :handler_hierarchy
    self.handler_hierarchy ||= []

    # @private
    @@handler_list = []

    # Register the class's handler
    #
    # @param [Symbol] handler the handler name
    def self.register(handler)
      @@handler_list << handler
      self.handler_hierarchy = [handler] + self.handler_hierarchy
    end

    # The list of registered handlers
    #
    # @return [Array<Symbol>] a list of currently registered handlers
    def self.handler_list
      @@handler_list
    end

    register :error

    # @private
    # HACK!! until I can refactor the entire Error object model
    def id
      nil
    end
  end  # BlatherError

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

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

    def initialize(node)
      @node = node
    end
  end  # UnknownResponse

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

    def initialize(msg)
      @message = msg.to_s
    end
  end  # ParseError

end  # Blather

Version data entries

34 entries across 34 versions & 2 rubygems

Version Path
blather-2.0.0 lib/blather/errors.rb
blather-1.2.0 lib/blather/errors.rb
blather-1.1.4 lib/blather/errors.rb
blather-1.1.3 lib/blather/errors.rb
blather-1.1.2 lib/blather/errors.rb
blather-1.1.1 lib/blather/errors.rb
blather-1.1.0 lib/blather/errors.rb
blather-1.0.0 lib/blather/errors.rb
blather-0.8.8 lib/blather/errors.rb
blather-0.8.7 lib/blather/errors.rb
blather-0.8.6 lib/blather/errors.rb
blather-0.8.5 lib/blather/errors.rb
blather-0.8.4 lib/blather/errors.rb
blather-0.8.3 lib/blather/errors.rb
blather-0.8.2 lib/blather/errors.rb
tp-blather-0.8.5 lib/blather/errors.rb
tp-blather-0.8.4 lib/blather/errors.rb
tp-blather-0.8.3 lib/blather/errors.rb
tp-blather-0.8.2 lib/blather/errors.rb
blather-0.8.1 lib/blather/errors.rb