Sha256: 805d327d69fd27432d897c5fa2ad2fb2ee75168b0e809a5a8d8aaec1f7317d6c

Contents?: true

Size: 758 Bytes

Versions: 1

Compression:

Stored size: 758 Bytes

Contents

module Blather
  # Main error class
  class BlatherError < StandardError; end

    #Parse Errors
    class ParseError < BlatherError; end

    # Stream errors
    class StreamError < BlatherError
      attr_accessor :type, :text

      def initialize(node)
        @type = node.detect { |n| n.name != 'text' && n['xmlns'] == 'urn:ietf:params:xml:ns:xmpp-streams' }
        @text = node.detect { |n| n.name == 'text' }

        @extra = node.detect { |n| n['xmlns'] != 'urn:ietf:params:xml:ns:xmpp-streams' }
      end

      def to_s
        "Stream Error (#{type.name}) #{"[#{@extra.name}]" if @extra}: #{text.content if text}"
      end
    end

    # Stanza errors
    class StanzaError < BlatherError; end
      class ArgumentError < StanzaError; end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
blather-0.2.1 lib/blather/errors.rb