Class Jabber::Error
In: lib/xmpp4r/error.rb
Parent: XMPPElement
Message Presence XMPPStanza Iq Singleton IdGenerator XMPPElement X IqQuery Error Connection Client Component Client Comparable JID RuntimeError AuthenticationFailure ErrorException NoNameXmlnsRegistered SOCKS5Error REXML::Element Stream SOCKS5Bytestreams SOCKS5BytestreamsTarget SOCKS5BytestreamsInitiator XMPPElement StreamHost IqSiFileRange IqSiFile StreamHostUsed IqSi XRosterItem RosterItem IqFeature XMUCUserItem XMUCUserInvite IqPubSub Items Subscription IqPubSubOwner Item Event Feature Item Identity XDataField XDataReported XDataTitle XDataInstructions IqVcard SOCKS5BytestreamsServerStreamHost TCPSocket SOCKS5Socket IqQuery IqQueryBytestreams IqQueryVersion IqQueryRoster IqQueryMUCOwner IqQueryRPC IqQueryDiscoItems IqQueryDiscoInfo IBB IBBTarget IBBInitiator Responder SimpleResponder Iq IqCommand RosterXItem XRoster RosterX X XMUCUser XMUC XDelay XData XParent MUCClient SimpleMUCClient XMLRPC::ParserWriterChooseMixin Client Server XMLRPC::ParseContentType XMLRPC::BasicServer Base DigestMD5 Plain ServiceHelper NodeHelper FileSource CallbackList Callback Semaphore StreamParser SOCKS5BytestreamsPeer SOCKS5BytestreamsServer IBBQueueItem Responder Helper MUCBrowser NodeBrowser Helper Helper lib/xmpp4r/authenticationfailure.rb lib/xmpp4r/xmppstanza.rb lib/xmpp4r/callbacks.rb lib/xmpp4r/idgenerator.rb lib/xmpp4r/connection.rb lib/xmpp4r/iq.rb lib/xmpp4r/jid.rb lib/xmpp4r/errorexception.rb lib/xmpp4r/client.rb lib/xmpp4r/stream.rb lib/xmpp4r/semaphore.rb lib/xmpp4r/streamparser.rb lib/xmpp4r/x.rb lib/xmpp4r/error.rb lib/xmpp4r/component.rb lib/xmpp4r/query.rb lib/xmpp4r/xmppelement.rb lib/xmpp4r/message.rb lib/xmpp4r/presence.rb lib/xmpp4r/bytestreams/helper/ibb/initiator.rb lib/xmpp4r/bytestreams/iq/si.rb lib/xmpp4r/bytestreams/iq/bytestreams.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/base.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/server.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/socks5.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/initiator.rb lib/xmpp4r/bytestreams/helper/ibb/base.rb lib/xmpp4r/bytestreams/helper/ibb/target.rb Bytestreams XParent lib/xmpp4r/version/iq/version.rb lib/xmpp4r/version/helper/responder.rb lib/xmpp4r/version/helper/simpleresponder.rb Version lib/xmpp4r/command/iq/command.rb lib/xmpp4r/command/helper/responder.rb Command lib/xmpp4r/roster/helper/roster.rb lib/xmpp4r/roster/iq/roster.rb lib/xmpp4r/roster/x/roster.rb Roster lib/xmpp4r/feature_negotiation/iq/feature.rb FeatureNegotiation lib/xmpp4r/muc/x/muc.rb lib/xmpp4r/muc/helper/mucclient.rb lib/xmpp4r/muc/x/mucuseritem.rb lib/xmpp4r/muc/helper/mucbrowser.rb lib/xmpp4r/muc/x/mucuserinvite.rb lib/xmpp4r/muc/iq/mucowner.rb lib/xmpp4r/muc/helper/simplemucclient.rb MUC lib/xmpp4r/rpc/helper/server.rb lib/xmpp4r/rpc/helper/client.rb lib/xmpp4r/rpc/iq/rpc.rb RPC lib/xmpp4r/sasl.rb SASL lib/xmpp4r/delay/x/delay.rb Delay lib/xmpp4r/pubsub/stanzas/subscription.rb lib/xmpp4r/pubsub/helper/servicehelper.rb lib/xmpp4r/pubsub/stanzas/item.rb lib/xmpp4r/pubsub/helper/nodehelper.rb lib/xmpp4r/pubsub/iq/pubsub.rb lib/xmpp4r/pubsub/stanzas/event.rb lib/xmpp4r/pubsub/helper/nodebrowser.rb lib/xmpp4r/pubsub/stanzas/items.rb PubSub lib/xmpp4r/httpbinding/client.rb HTTPBinding lib/xmpp4r/bytestreams/helper/filetransfer.rb TransferSource FileTransfer lib/xmpp4r/discovery/iq/discoinfo.rb lib/xmpp4r/discovery/iq/discoitems.rb Discovery lib/xmpp4r/dataforms/x/data.rb Dataforms lib/xmpp4r/vcard/helper/vcard.rb lib/xmpp4r/vcard/iq/vcard.rb Vcard Jabber dot/m_80_0.png

A class used to build/parse <error/> elements. Look at JEP 0086 for explanation.

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

Does also set type and code to appropriate values according to errorcondition

text: [nil] or [String] Error text

[Source]

    # File lib/xmpp4r/error.rb, line 41
41:     def initialize(errorcondition=nil, text=nil)
42:       if errorcondition.nil?
43:         super()
44:         set_text(text) unless text.nil?
45:       else
46:         errortype = nil
47:         errorcode = nil
48:         @@Errors.each { |cond,type,code|
49:           if errorcondition == cond
50:             errortype = type
51:             errorcode = code
52:           end
53:         }
54: 
55:         if errortype.nil? || errorcode.nil?
56:           raise("Unknown error condition when initializing Error")
57:         end
58:         
59:         super()
60:         set_error(errorcondition)
61:         set_type(errortype)
62:         set_code(errorcode)
63:         set_text(text) unless text.nil?
64:       end
65:     end

Public Instance methods

Get the ‘Legacy error code’ or nil

result:[Integer] Error code

[Source]

    # File lib/xmpp4r/error.rb, line 70
70:     def code
71:       if attributes['code']
72:         attributes['code'].to_i
73:       else
74:         nil
75:       end
76:     end

Set the ‘Legacy error code’ or nil

i:[Integer] Error code

[Source]

    # File lib/xmpp4r/error.rb, line 81
81:     def code=(i)
82:       if i.nil?
83:         attributes['code'] = nil
84:       else
85:         attributes['code'] = i.to_s
86:       end
87:     end

Get the ‘XMPP error condition‘

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

[Source]

     # File lib/xmpp4r/error.rb, line 101
101:     def error
102:       name = nil
103:       each_element { |e| name = e.name if (e.namespace == 'urn:ietf:params:xml:ns:xmpp-stanzas') && (e.name != 'text') }
104:       name
105:     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/error.rb, line 114
114:     def error=(s)
115:       xe = nil
116:       each_element { |e| xe = e if (e.namespace == 'urn:ietf:params:xml:ns:xmpp-stanzas') && (e.name != 'text') }
117:       unless xe.nil?
118:         delete_element(xe)
119:       end
120: 
121:       add_element(s).add_namespace('urn:ietf:params:xml:ns:xmpp-stanzas')
122:     end

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

[Source]

    # File lib/xmpp4r/error.rb, line 91
91:     def set_code(i)
92:       self.code = i
93:       self
94:     end

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

[Source]

     # File lib/xmpp4r/error.rb, line 126
126:     def set_error(s)
127:       self.error = s
128:       self
129:     end

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

[Source]

     # File lib/xmpp4r/error.rb, line 154
154:     def set_text(s)
155:       self.text = s
156:       self
157:     end

Set the type of error (chaining-friendly)

[Source]

     # File lib/xmpp4r/error.rb, line 194
194:     def set_type(t)
195:       self.type = t
196:       self
197:     end

Get the errors <text/> element text

result:[String] or nil

[Source]

     # File lib/xmpp4r/error.rb, line 134
134:     def text
135:       first_element_text('text') || super
136:     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/error.rb, line 142
142:     def text=(s)
143:       delete_elements('text')
144: 
145:       unless s.nil?
146:         e = add_element('text')
147:         e.add_namespace('urn:ietf:params:xml:ns:xmpp-stanzas')
148:         e.text = s
149:       end
150:     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/error.rb, line 168
168:     def type
169:       case attributes['type']
170:         when 'auth' then :auth
171:         when 'cancel' then :cancel
172:         when 'continue' then :continue
173:         when 'modify' then :modify
174:         when 'wait' then :wait
175:         else nil
176:       end
177:     end

Set the type of error (see Error#type)

[Source]

     # File lib/xmpp4r/error.rb, line 181
181:     def type=(t)
182:       case t
183:         when :auth then attributes['type'] = 'auth'
184:         when :cancel then attributes['type'] = 'cancel'
185:         when :continue then attributes['type'] = 'continue'
186:         when :modify then attributes['type'] = 'modify'
187:         when :wait then attributes['type'] = 'wait'
188:         else attributes['type'] = nil
189:       end
190:     end

[Validate]