Class Jabber::ErrorResponse
In: lib/xmpp4r/errors.rb
Parent: XMPPElement
Message Presence XMPPStanza Iq XMPPElement ErrorResponse X IqQuery JabberError ComponentAuthenticationFailure ArgumentError InvalidChatState SOCKS5Error ServerError NoNameXmlnsRegistered ServerDisconnected ClientAuthenticationFailure Connection Client Component Connection Client Singleton IdGenerator Comparable JID Enumerable CallbackList Items Publish StandardError REXML::Element Stream XMPPElement Location IqFeature StreamHost IqSiFile IqSiFileRange IqSi StreamHostUsed XRosterItem RosterItem C Body HTML UserItem XMUCUserInvite Configuration Retract IqPubSub Item IqPubSubOwner Event Subscription Unsubscribe Tune XDataField XDataReported XDataTitle XDataInstructions Feature Item Identity IqVcard PubSub::ServiceHelper Helper Helper SOCKS5Bytestreams SOCKS5BytestreamsTarget SOCKS5BytestreamsInitiator SOCKS5BytestreamsServerStreamHost TCPSocket SOCKS5Socket IqQuery IqQueryBytestreams IqQueryRoster IqQueryVersion IqQueryRPC IqQueryMUCOwner IqQueryMUCAdmin IqQueryDiscoItems IqQueryDiscoInfo IqQueryLastActivity IBB IBBTarget IBBInitiator RosterXItem XRoster RosterX X XDelay XMUC XMUCUser XData Responder SimpleResponder Iq IqCommand XMLRPC::ParserWriterChooseMixin Client Server XMLRPC::ParseContentType XMLRPC::BasicServer MUCClient SimpleMUCClient MUC::UserItem XMUCUserItem IqQueryMUCAdminItem XParent SubscriptionConfig NodeConfig OwnerNodeConfig EventItems ServiceHelper OAuthServiceHelper NodeHelper EventItem Base Anonymous DigestMD5 Plain FileSource Base Bot Callback StreamParser Semaphore SOCKS5BytestreamsPeer SOCKS5BytestreamsServer IBBQueueItem Helper Responder Helper Listener MUCBrowser NodeBrowser ListenerMocker Helper Responder Helper Helper Helper lib/xmpp4r/message.rb lib/xmpp4r/connection.rb lib/xmpp4r/xmppstanza.rb lib/xmpp4r/iq.rb lib/xmpp4r/callbacks.rb lib/xmpp4r/idgenerator.rb lib/xmpp4r/stream.rb lib/xmpp4r/client.rb lib/xmpp4r/jid.rb lib/xmpp4r/x.rb lib/xmpp4r/streamparser.rb lib/xmpp4r/semaphore.rb lib/xmpp4r/errors.rb lib/xmpp4r/component.rb lib/xmpp4r/presence.rb lib/xmpp4r/xmppelement.rb lib/xmpp4r/query.rb XParent lib/xmpp4r/location/helper/helper.rb lib/xmpp4r/location/location.rb UserLocation lib/xmpp4r/feature_negotiation/iq/feature.rb FeatureNegotiation lib/xmpp4r/bytestreams/iq/si.rb lib/xmpp4r/bytestreams/helper/ibb/initiator.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/base.rb lib/xmpp4r/bytestreams/iq/bytestreams.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/initiator.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/socks5.rb lib/xmpp4r/bytestreams/helper/ibb/target.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/server.rb lib/xmpp4r/bytestreams/helper/ibb/base.rb Bytestreams lib/xmpp4r/roster/x/roster.rb lib/xmpp4r/roster/helper/roster.rb lib/xmpp4r/roster/iq/roster.rb Roster lib/xmpp4r/version/helper/responder.rb lib/xmpp4r/version/helper/simpleresponder.rb lib/xmpp4r/version/iq/version.rb Version lib/xmpp4r/command/iq/command.rb lib/xmpp4r/command/helper/responder.rb Command lib/xmpp4r/caps/helper/helper.rb lib/xmpp4r/caps/c.rb Caps lib/xmpp4r/reliable.rb Reliable lib/xmpp4r/delay/x/delay.rb Delay lib/xmpp4r/xhtml/html.rb XHTML lib/xmpp4r/rpc/helper/server.rb lib/xmpp4r/rpc/helper/client.rb lib/xmpp4r/rpc/iq/rpc.rb RPC lib/xmpp4r/muc/iq/mucadminitem.rb lib/xmpp4r/muc/x/muc.rb lib/xmpp4r/muc/item.rb lib/xmpp4r/muc/helper/simplemucclient.rb lib/xmpp4r/muc/iq/mucadmin.rb lib/xmpp4r/muc/helper/mucbrowser.rb lib/xmpp4r/muc/x/mucuseritem.rb lib/xmpp4r/muc/x/mucuserinvite.rb lib/xmpp4r/muc/iq/mucowner.rb lib/xmpp4r/muc/helper/mucclient.rb MUC lib/xmpp4r/pubsub/children/item.rb lib/xmpp4r/pubsub/children/configuration.rb lib/xmpp4r/pubsub/children/subscription.rb lib/xmpp4r/pubsub/helper/servicehelper.rb lib/xmpp4r/pubsub/children/unsubscribe.rb lib/xmpp4r/pubsub/children/publish.rb lib/xmpp4r/pubsub/helper/oauth_service_helper.rb lib/xmpp4r/pubsub/children/event.rb lib/xmpp4r/pubsub/iq/pubsub.rb lib/xmpp4r/pubsub/children/retract.rb lib/xmpp4r/pubsub/helper/nodebrowser.rb lib/xmpp4r/pubsub/helper/nodehelper.rb lib/xmpp4r/pubsub/children/items.rb lib/xmpp4r/pubsub/children/subscription_config.rb lib/xmpp4r/pubsub/children/node_config.rb OAuthPubSubStreamHelper PubSub lib/xmpp4r/httpbinding/client.rb HTTPBinding lib/xmpp4r/tune/helper/helper.rb lib/xmpp4r/tune/tune.rb UserTune lib/xmpp4r/sasl.rb SASL lib/xmpp4r/test/listener_mocker.rb Test lib/xmpp4r/dataforms/x/data.rb Dataforms lib/xmpp4r/discovery/helper/helper.rb lib/xmpp4r/discovery/iq/discoinfo.rb lib/xmpp4r/discovery/helper/responder.rb lib/xmpp4r/discovery/iq/discoitems.rb Discovery lib/xmpp4r/bytestreams/helper/filetransfer.rb TransferSource FileTransfer lib/xmpp4r/last/helper/helper.rb lib/xmpp4r/last/iq/last.rb LastActivity lib/xmpp4r/framework/base.rb lib/xmpp4r/framework/bot.rb Framework lib/xmpp4r/vcard/helper/vcard.rb lib/xmpp4r/vcard/iq/vcard.rb Vcard Jabber dot/m_110_0.png

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?

Methods

code   code=   error   error=   new   set_code   set_error   set_text   set_type   text   text=   type   type=  

Public Class methods

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

[Source]

     # File lib/xmpp4r/errors.rb, line 100
100:     def initialize(errorcondition=nil, text=nil)
101:       if errorcondition.nil?
102:         super()
103:         set_text(text) unless text.nil?
104:       else
105:         errortype = nil
106:         errorcode = nil
107:         @@Errors.each { |cond,type,code|
108:           if errorcondition == cond
109:             errortype = type
110:             errorcode = code
111:           end
112:         }
113: 
114:         if errortype.nil? || errorcode.nil?
115:           raise ArgumentError, "Unknown error condition when initializing ErrorReponse"
116:         end
117: 
118:         super()
119:         set_error(errorcondition)
120:         set_type(errortype)
121:         set_code(errorcode)
122:         set_text(text) unless text.nil?
123:       end
124:     end

Public Instance methods

Get the ‘Legacy error code’ or nil

result:[Integer] Error code

[Source]

     # File lib/xmpp4r/errors.rb, line 129
129:     def code
130:       if attributes['code']
131:         attributes['code'].to_i
132:       else
133:         nil
134:       end
135:     end

Set the ‘Legacy error code’ or nil

i:[Integer] Error code

[Source]

     # File lib/xmpp4r/errors.rb, line 140
140:     def code=(i)
141:       if i.nil?
142:         attributes['code'] = nil
143:       else
144:         attributes['code'] = i.to_s
145:       end
146:     end

Get the ‘XMPP error condition‘

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

[Source]

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

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

[Source]

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

Set the ‘Legacy error code’ (chaining-friendly)

[Source]

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

Set the ‘XMPP error condition’ (chaining-friendly)

[Source]

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

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

[Source]

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

Set the type of error (chaining-friendly)

[Source]

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

Get the errors <text/> element text

result:[String] or nil

[Source]

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

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

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

[Source]

     # File lib/xmpp4r/errors.rb, line 201
201:     def text=(s)
202:       delete_elements('text')
203: 
204:       unless s.nil?
205:         e = add_element('text')
206:         e.add_namespace('urn:ietf:params:xml:ns:xmpp-stanzas')
207:         e.text = s
208:       end
209:     end

Get the type of error (meaning how to proceed)

result:[Symbol] or [nil] as following:
  • :auth
  • :cancel
  • :continue
  • :modify
  • :wait

[Source]

     # File lib/xmpp4r/errors.rb, line 227
227:     def type
228:       case attributes['type']
229:         when 'auth' then :auth
230:         when 'cancel' then :cancel
231:         when 'continue' then :continue
232:         when 'modify' then :modify
233:         when 'wait' then :wait
234:         else nil
235:       end
236:     end

Set the type of error (see ErrorResponse#type)

[Source]

     # File lib/xmpp4r/errors.rb, line 240
240:     def type=(t)
241:       case t
242:         when :auth then attributes['type'] = 'auth'
243:         when :cancel then attributes['type'] = 'cancel'
244:         when :continue then attributes['type'] = 'continue'
245:         when :modify then attributes['type'] = 'modify'
246:         when :wait then attributes['type'] = 'wait'
247:         else attributes['type'] = nil
248:       end
249:     end

[Validate]