Sha256: dcac5d3a9ae690743981ac8253b7f02924c2a25b2b842de44f5f46badda84f54

Contents?: true

Size: 699 Bytes

Versions: 1

Compression:

Stored size: 699 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 < StandardError; end
      class ArgumentError < StanzaError; end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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