Class Jabber::ErrorResponse
In: lib/xmpp4r/errors.rb
Parent: XMPPElement
Message Presence XMPPStanza Iq XMPPElement ErrorResponse X IqQuery JabberError ComponentAuthenticationFailure ArgumentError SOCKS5Error ServerError NoNameXmlnsRegistered ClientAuthenticationFailure Connection Client Component Client Singleton IdGenerator Comparable JID StandardError REXML::Element Stream IqQuery IqQueryVersion IqQueryRoster IqQueryBytestreams IqQueryRPC IqQueryMUCOwner IqQueryMUCAdmin IqQueryDiscoItems IqQueryDiscoInfo Responder SimpleResponder XRosterItem RosterXItem XMPPElement RosterItem IqFeature StreamHost IqSiFile IqSiFileRange IqSi StreamHostUsed C Body HTML UserItem XMUCUserInvite Tune Configuration Items Item IqPubSub Publish Event IqPubSubOwner Subscription Unsubscribe Feature Item Identity XDataField XDataReported XDataTitle XDataInstructions IqVcard XRoster RosterX X XMUC XMUCUser XDelay XData Iq IqCommand SOCKS5Bytestreams SOCKS5BytestreamsTarget SOCKS5BytestreamsInitiator SOCKS5BytestreamsServerStreamHost TCPSocket SOCKS5Socket IBB IBBTarget IBBInitiator XMLRPC::ParserWriterChooseMixin Client Server XMLRPC::ParseContentType XMLRPC::BasicServer MUCClient SimpleMUCClient MUC::UserItem XMUCUserItem IqQueryMUCAdminItem XParent Base Anonymous DigestMD5 Plain PubSub::ServiceHelper Helper SubscriptionConfig NodeConfig OwnerNodeConfig EventItems EventItem ServiceHelper NodeHelper FileSource Base Bot CallbackList Callback StreamParser Semaphore Helper Responder SOCKS5BytestreamsPeer SOCKS5BytestreamsServer IBBQueueItem Helper MUCBrowser NodeBrowser Responder 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/version/helper/responder.rb lib/xmpp4r/version/helper/simpleresponder.rb lib/xmpp4r/version/iq/version.rb Version lib/xmpp4r/roster/x/roster.rb lib/xmpp4r/roster/helper/roster.rb lib/xmpp4r/roster/iq/roster.rb Roster lib/xmpp4r/feature_negotiation/iq/feature.rb FeatureNegotiation lib/xmpp4r/command/iq/command.rb lib/xmpp4r/command/helper/responder.rb Command 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/caps/helper/helper.rb lib/xmpp4r/caps/c.rb Caps 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/delay/x/delay.rb Delay lib/xmpp4r/sasl.rb SASL lib/xmpp4r/tune/helper/helper.rb lib/xmpp4r/tune/tune.rb UserTune 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/children/event.rb lib/xmpp4r/pubsub/iq/pubsub.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 PubSub lib/xmpp4r/httpbinding/client.rb HTTPBinding lib/xmpp4r/discovery/iq/discoinfo.rb lib/xmpp4r/discovery/helper/responder.rb lib/xmpp4r/discovery/iq/discoitems.rb Discovery lib/xmpp4r/dataforms/x/data.rb Dataforms lib/xmpp4r/bytestreams/helper/filetransfer.rb TransferSource FileTransfer lib/xmpp4r/vcard/helper/vcard.rb lib/xmpp4r/vcard/iq/vcard.rb Vcard lib/xmpp4r/framework/base.rb lib/xmpp4r/framework/bot.rb Framework Jabber dot/m_99_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 97
 97:     def initialize(errorcondition=nil, text=nil)
 98:       if errorcondition.nil?
 99:         super()
100:         set_text(text) unless text.nil?
101:       else
102:         errortype = nil
103:         errorcode = nil
104:         @@Errors.each { |cond,type,code|
105:           if errorcondition == cond
106:             errortype = type
107:             errorcode = code
108:           end
109:         }
110: 
111:         if errortype.nil? || errorcode.nil?
112:           raise ArgumentError, "Unknown error condition when initializing ErrorReponse"
113:         end
114: 
115:         super()
116:         set_error(errorcondition)
117:         set_type(errortype)
118:         set_code(errorcode)
119:         set_text(text) unless text.nil?
120:       end
121:     end

Public Instance methods

Get the ‘Legacy error code’ or nil

result:[Integer] Error code

[Source]

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

Set the ‘Legacy error code’ or nil

i:[Integer] Error code

[Source]

     # File lib/xmpp4r/errors.rb, line 137
137:     def code=(i)
138:       if i.nil?
139:         attributes['code'] = nil
140:       else
141:         attributes['code'] = i.to_s
142:       end
143:     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 157
157:     def error
158:       name = nil
159:       each_element { |e| name = e.name if (e.namespace == 'urn:ietf:params:xml:ns:xmpp-stanzas') && (e.name != 'text') }
160:       name
161:     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 170
170:     def error=(s)
171:       xe = nil
172:       each_element { |e| xe = e if (e.namespace == 'urn:ietf:params:xml:ns:xmpp-stanzas') && (e.name != 'text') }
173:       unless xe.nil?
174:         delete_element(xe)
175:       end
176: 
177:       add_element(s).add_namespace('urn:ietf:params:xml:ns:xmpp-stanzas')
178:     end

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

[Source]

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

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

[Source]

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

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

[Source]

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

Set the type of error (chaining-friendly)

[Source]

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

Get the errors <text/> element text

result:[String] or nil

[Source]

     # File lib/xmpp4r/errors.rb, line 190
190:     def text
191:       first_element_text('text') || super
192:     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 198
198:     def text=(s)
199:       delete_elements('text')
200: 
201:       unless s.nil?
202:         e = add_element('text')
203:         e.add_namespace('urn:ietf:params:xml:ns:xmpp-stanzas')
204:         e.text = s
205:       end
206:     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 224
224:     def type
225:       case attributes['type']
226:         when 'auth' then :auth
227:         when 'cancel' then :cancel
228:         when 'continue' then :continue
229:         when 'modify' then :modify
230:         when 'wait' then :wait
231:         else nil
232:       end
233:     end

Set the type of error (see ErrorResponse#type)

[Source]

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

[Validate]