Sha256: d2183e9af8a2ffa70093647dd1c374b6209623a9e87ecc1680372dee633edf5a

Contents?: true

Size: 698 Bytes

Versions: 2

Compression:

Stored size: 698 Bytes

Contents

module Blather
  # Main error class
  class BlatherError < StandardError; 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

2 entries across 2 versions & 1 rubygems

Version Path
blather-0.1 lib/blather/core/errors.rb
blather-0.2 lib/blather/errors.rb