### Home Classes Methods

### In Files

- lib/xmpp4r/errors.rb

### Parent

XMPPElement

### Methods

- ::new
- #code
- #code=
- #error
- #error=
- #set_code
- #set_error
- #set_text
- #set_type
- #text
- #text=
- #type
- #type=

### Files

- CHANGELOG
- COPYING
- LICENSE
- README.rdoc
- README_ruby19.txt

### Class/Module Index

Quicksearch

- Jabber
- Jabber::ArgumentError
- Jabber::Bytestreams
- Jabber::Bytestreams::IBB
- Jabber::Bytestreams::IBBInitiator
- Jabber::Bytestreams::IBBQueueItem
- Jabber::Bytestreams::IBBTarget
- Jabber::Bytestreams::IqQueryBytestreams
- Jabber::Bytestreams::IqSi
- Jabber::Bytestreams::IqSiFile
- Jabber::Bytestreams::IqSiFileRange
- Jabber::Bytestreams::SOCKS5Bytestreams
- Jabber::Bytestreams::SOCKS5BytestreamsInitiator
- Jabber::Bytestreams::SOCKS5BytestreamsPeer
- Jabber::Bytestreams::SOCKS5BytestreamsServer
- Jabber::Bytestreams::SOCKS5BytestreamsServerStreamHost
- Jabber::Bytestreams::SOCKS5BytestreamsTarget
- Jabber::Bytestreams::SOCKS5Socket
- Jabber::Bytestreams::StreamHost
- Jabber::Bytestreams::StreamHostUsed
- Jabber::Callback
- Jabber::CallbackList
- Jabber::Caps
- Jabber::Caps::C
- Jabber::Caps::Helper
- Jabber::Client
- Jabber::ClientAuthenticationFailure
- Jabber::Command
- Jabber::Command::IqCommand
- Jabber::Command::Responder
- Jabber::Component
- Jabber::ComponentAuthenticationFailure
- Jabber::Connection
- Jabber::Connection::SSLSocketUTF8
- Jabber::Dataforms
- Jabber::Dataforms::XData
- Jabber::Dataforms::XDataField
- Jabber::Dataforms::XDataInstructions
- Jabber::Dataforms::XDataReported
- Jabber::Dataforms::XDataTitle
- Jabber::Delay
- Jabber::Delay::XDelay
- Jabber::Discovery
- Jabber::Discovery::Feature
- Jabber::Discovery::Helper
- Jabber::Discovery::Identity
- Jabber::Discovery::IqQueryDiscoInfo
- Jabber::Discovery::IqQueryDiscoItems
- Jabber::Discovery::Item
- Jabber::Discovery::Responder
- Jabber::EntityTime
- Jabber::EntityTime::IqTime
- Jabber::EntityTime::Responder
- Jabber::ErrorResponse
- Jabber::FeatureNegotiation
- Jabber::FeatureNegotiation::IqFeature
- Jabber::FileTransfer
- Jabber::FileTransfer::FileSource
- Jabber::FileTransfer::Helper
- Jabber::FileTransfer::TransferSource
- Jabber::Framework
- Jabber::Framework::Base
- Jabber::Framework::Bot
- Jabber::HTTPBinding
- Jabber::HTTPBinding::Client
- Jabber::IdGenerator
- Jabber::InvalidChatState
- Jabber::Iq
- Jabber::IqQuery
- Jabber::JID
- Jabber::JabberError
- Jabber::LastActivity
- Jabber::LastActivity::Helper
- Jabber::LastActivity::IqQueryLastActivity
- Jabber::MUC
- Jabber::MUC::IqQueryMUCAdmin
- Jabber::MUC::IqQueryMUCAdminItem
- Jabber::MUC::IqQueryMUCOwner
- Jabber::MUC::MUCBrowser
- Jabber::MUC::MUCClient
- Jabber::MUC::SimpleMUCClient
- Jabber::MUC::UserItem
- Jabber::MUC::XMUC
- Jabber::MUC::XMUCUser
- Jabber::MUC::XMUCUserInvite
- Jabber::MUC::XMUCUserItem
- Jabber::Message
- Jabber::NoNameXmlnsRegistered
- Jabber::NotConnected
- Jabber::Observable
- Jabber::Observable::Contact
- Jabber::Observable::PubSub
- Jabber::Observable::PubSub::AlreadySet
- Jabber::Observable::PubSub::NoService
- Jabber::Observable::Subscriptions
- Jabber::Presence
- Jabber::PubSub
- Jabber::PubSub::Configuration
- Jabber::PubSub::Event
- Jabber::PubSub::EventItem
- Jabber::PubSub::EventItems
- Jabber::PubSub::IqPubSub
- Jabber::PubSub::IqPubSubOwner
- Jabber::PubSub::Item
- Jabber::PubSub::Items
- Jabber::PubSub::NodeBrowser
- Jabber::PubSub::NodeConfig
- Jabber::PubSub::NodeHelper
- Jabber::PubSub::OAuthPubSubStreamHelper
- Jabber::PubSub::OAuthServiceHelper
- Jabber::PubSub::OwnerNodeConfig
- Jabber::PubSub::Publish
- Jabber::PubSub::Retract
- Jabber::PubSub::ServiceHelper
- Jabber::PubSub::Subscription
- Jabber::PubSub::SubscriptionConfig
- Jabber::PubSub::Unsubscribe
- Jabber::RPC
- Jabber::RPC::Client
- Jabber::RPC::IqQueryRPC
- Jabber::RPC::Server
- Jabber::Reliable
- Jabber::Reliable::Connection
- Jabber::Reliable::Listener
- Jabber::Roster
- Jabber::Roster::Helper
- Jabber::Roster::Helper::RosterItem
- Jabber::Roster::IqQueryRoster
- Jabber::Roster::RosterItem
- Jabber::Roster::RosterX
- Jabber::Roster::RosterXItem
- Jabber::Roster::XRoster
- Jabber::Roster::XRosterItem
- Jabber::SASL
- Jabber::SASL::Anonymous
- Jabber::SASL::Base
- Jabber::SASL::DigestMD5
- Jabber::SASL::Plain
- Jabber::SOCKS5Error
- Jabber::Semaphore
- Jabber::ServerDisconnected
- Jabber::Stream
- Jabber::Stream::ThreadBlock
- Jabber::StreamParser
- Jabber::Test
- Jabber::Test::ListenerMocker
- Jabber::UserLocation
- Jabber::UserLocation::Helper
- Jabber::UserLocation::Location
- Jabber::UserTune
- Jabber::UserTune::Helper
- Jabber::UserTune::Tune
- Jabber::Vcard
- Jabber::Vcard::Helper
- Jabber::Vcard::IqVcard
- Jabber::Version
- Jabber::Version::IqQueryVersion
- Jabber::Version::Responder
- Jabber::Version::SimpleResponder
- Jabber::X
- Jabber::XHTML
- Jabber::XHTML::Body
- Jabber::XHTML::HTML
- Jabber::XMPPElement
- Jabber::XMPPStanza
- Jabber::XParent
- REXML
- REXML::Element
- REXML::IOSource
- XMLRPC
- XMLRPC::Create
- Base64
- ObservableThing
- QObserver
- ThreadStore

No matching classes.

# Jabber::ErrorResponse

A class used to build/parse <error/> elements. Look at XEP-0086 for explanation: www.xmpp.org/extensions/xep-0086.html

FIXME : XEP-0086 is officially deprecated. What effect does that have on this class? Any?

### Public Class Methods

new(errorcondition=nil, text=nil) click to toggle source

errorcondition

nil

  or [String] of the following:

- "bad-request"

- "conflict"

- "feature-not-implemented"

- "forbidden"

- "gone"

- "internal-server-error"

- "item-not-found"

- "jid-malformed"

- "not-acceptable"

- "not-allowed"

- "not-authorized"

- "payment-required"

- "recipient-unavailable"

- "redirect"

- "registration-required"

- "remote-server-not-found"

- "remote-server-timeout"

- "resource-constraint"

- "service-unavailable"

- "subscription-required"

- "undefined-condition"

- "unexpected-request"

Will raise an [Exception] if not [nil] and none of the above

Also sets type and code to appropriate values according to errorcondition

text: [nil] or [String] ErrorResponse text

    # File lib/xmpp4r/errors.rb, line 100
    def initialize(errorcondition=nil, text=nil)
      if errorcondition.nil?
        super()
        set_text(text) unless text.nil?
      else
        errortype = nil
        errorcode = nil
        @@Errors.each { |cond,type,code|
          if errorcondition == cond
            errortype = type
            errorcode = code
          end
        }

        if errortype.nil? || errorcode.nil?
          raise ArgumentError, "Unknown error condition when initializing ErrorReponse"
        end

        super()
        set_error(errorcondition)
        set_type(errortype)
        set_code(errorcode)
        set_text(text) unless text.nil?
      end
    end

### Public Instance Methods

code() click to toggle source

Get the 'Legacy error code' or nil

result

Integer

  Error code

    # File lib/xmpp4r/errors.rb, line 129
    def code
      if attributes['code']
        attributes['code'].to_i
      else
        nil
      end
    end

code=(i) click to toggle source

Set the 'Legacy error code' or nil

i

Integer

  Error code

    # File lib/xmpp4r/errors.rb, line 140
    def code=(i)
      if i.nil?
        attributes['code'] = nil
      else
        attributes['code'] = i.to_s
      end
    end

error() click to toggle source

Get the 'XMPP error condition'

This can be anything that possess the specific namespace, checks don't apply here

    # File lib/xmpp4r/errors.rb, line 160
    def error
      name = nil
      each_element { |e| name = e.name if (e.namespace == 'urn:ietf:params:xml:ns:xmpp-stanzas') && (e.name != 'text') }
      name
    end

error=(s) click to toggle source

Set the 'XMPP error condition'

One previous element with that namespace will be deleted before

s

String

  Name of the element to be added,

namespace will be added automatically, checks don't apply here

    # File lib/xmpp4r/errors.rb, line 173
    def error=(s)
      xe = nil
      each_element { |e| xe = e if (e.namespace == 'urn:ietf:params:xml:ns:xmpp-stanzas') && (e.name != 'text') }
      unless xe.nil?
        delete_element(xe)
      end

      add_element(s).add_namespace('urn:ietf:params:xml:ns:xmpp-stanzas')
    end

set_code(i) click to toggle source

Set the 'Legacy error code' (chaining-friendly)

    # File lib/xmpp4r/errors.rb, line 150
    def set_code(i)
      self.code = i
      self
    end

set_error(s) click to toggle source

Set the 'XMPP error condition' (chaining-friendly)

    # File lib/xmpp4r/errors.rb, line 185
    def set_error(s)
      self.error = s
      self
    end

set_text(s) click to toggle source

Set the errors <text/> element text (chaining-friendly)

    # File lib/xmpp4r/errors.rb, line 213
    def set_text(s)
      self.text = s
      self
    end

set_type(t) click to toggle source

Set the type of error (chaining-friendly)

    # File lib/xmpp4r/errors.rb, line 253
    def set_type(t)
      self.type = t
      self
    end

text() click to toggle source

Get the errors <text/> element text

result

String

  or nil

    # File lib/xmpp4r/errors.rb, line 193
    def text
      first_element_text('text') || super
    end

text=(s) click to toggle source

Set the errors <text/> element text (Previous <text/> elements will be deleted first)

s

String

  <text/> content or [nil] if no <text/> element

    # File lib/xmpp4r/errors.rb, line 201
    def text=(s)
      delete_elements('text')

      unless s.nil?
        e = add_element('text')
        e.add_namespace('urn:ietf:params:xml:ns:xmpp-stanzas')
        e.text = s
      end
    end

type() click to toggle source

Get the type of error (meaning how to proceed)

result

Symbol

  or [nil] as following:

- :auth

- :cancel

- :continue

- :modify

- :wait

    # File lib/xmpp4r/errors.rb, line 227
    def type
      case attributes['type']
        when 'auth' then :auth
        when 'cancel' then :cancel
        when 'continue' then :continue
        when 'modify' then :modify
        when 'wait' then :wait
        else nil
      end
    end

type=(t) click to toggle source

Set the type of error (see ErrorResponse#type)

    # File lib/xmpp4r/errors.rb, line 240
    def type=(t)
      case t
        when :auth then attributes['type'] = 'auth'
        when :cancel then attributes['type'] = 'cancel'
        when :continue then attributes['type'] = 'continue'
        when :modify then attributes['type'] = 'modify'
        when :wait then attributes['type'] = 'wait'
        else attributes['type'] = nil
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.