Class: AgentXmpp::Xmpp::ErrorResponse
- Inherits:
-
Element
- Object
- REXML::Element
- Element
- AgentXmpp::Xmpp::ErrorResponse
- Defined in:
- lib/agent_xmpp/xmpp/error_response.rb
Overview
Constant Summary collapse
- @@Errors =
.….….….….….….….….….….….….….….….….….….….….….….….….……
[['bad-request', :modify, 400], ['conflict', :cancel, 409], ['feature-not-implemented', :cancel, 501], ['forbidden', :auth, 403], ['gone', :modify, 302], ['internal-server-error', :wait, 500], ['item-not-found', :cancel, 404], ['jid-malformed', :modify, 400], ['not-acceptable', :modify, 406], ['not-allowed', :cancel, 405], ['not-authorized', :auth, 401], ['payment-required', :auth, 402], ['recipient-unavailable', :wait, 404], ['redirect', :modify, 302], ['registration-required', :auth, 407], ['remote-server-not-found', :cancel, 404], ['remote-server-timeout', :wait, 504], ['resource-constraint', :wait, 500], ['service-unavailable', :cancel, 503], ['subscription-required', :auth, 407], ['undefined-condition', nil, 500], ['unexpected-request', :wait, 400]]
Class Method Summary collapse
-
.bad_request(params, msg) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.feature_not_implemented(request) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.forbidden(params) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.item_not_found(request) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.no_route(params) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.service_unavailable(request) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.unsupported_payload(params) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
Instance Method Summary collapse
-
#code ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#code=(i) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#error ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#error=(s) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#initialize(errorcondition = nil, text = nil) ⇒ ErrorResponse
constructor
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#text ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#text=(s) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
Methods inherited from Element
#<<, class_for_name_xmlns, #clone, import, name_xmlns, name_xmlns_for_class, #parent=, #set_xml_lang, #typed_add, #xml_lang, #xml_lang=, xmpp_attribute, xmpp_child
Methods inherited from REXML::Element
#delete_elements, #first_element, #first_element_text, #import, import, #replace_element_text, #typed_add
Constructor Details
#initialize(errorcondition = nil, text = nil) ⇒ ErrorResponse
.….….….….….….….….….….….….….….….….….….….….….….….….……
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/agent_xmpp/xmpp/error_response.rb', line 95 def initialize(errorcondition=nil, text=nil) if errorcondition.nil? super() else errortype = nil errorcode = nil @@Errors.each do |cond,type,code| if errorcondition == cond errortype = type errorcode = code end end raise ArgumentError, "Unknown error condition when initializing ErrorReponse" if errortype.nil? || errorcode.nil? super() self.error = errorcondition unless errorcondition.nil? self.type = errortype unless errortype.nil? self.code = errorcode unless errorcode.nil? end self.text = text unless text.nil? end |
Class Method Details
.bad_request(params, msg) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
26 27 28 |
# File 'lib/agent_xmpp/xmpp/error_response.rb', line 26 def bad_request(params, msg) command_error(params, 'bad-request', msg) end |
.feature_not_implemented(request) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
46 47 48 |
# File 'lib/agent_xmpp/xmpp/error_response.rb', line 46 def feature_not_implemented(request) iq_error(request, 'feature-not-implemented', 'feature not implemented') end |
.forbidden(params) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
41 42 43 |
# File 'lib/agent_xmpp/xmpp/error_response.rb', line 41 def forbidden(params) command_error(params, 'forbidden', 'the requesting JID is not allowed to execute the command') end |
.item_not_found(request) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
56 57 58 |
# File 'lib/agent_xmpp/xmpp/error_response.rb', line 56 def item_not_found(request) query_error(request, 'item-not-found', 'item not found') end |
.no_route(params) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
36 37 38 |
# File 'lib/agent_xmpp/xmpp/error_response.rb', line 36 def no_route(params) command_error(params, 'item-not-found', 'no route for specified command node') end |
.service_unavailable(request) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
51 52 53 |
# File 'lib/agent_xmpp/xmpp/error_response.rb', line 51 def service_unavailable(request) query_error(request, 'service-unavailable', 'service unavailable') end |
.unsupported_payload(params) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
31 32 33 |
# File 'lib/agent_xmpp/xmpp/error_response.rb', line 31 def unsupported_payload(params) command_error(params, 'bad-request', 'unsupported payload') end |
Instance Method Details
#code ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
117 118 119 |
# File 'lib/agent_xmpp/xmpp/error_response.rb', line 117 def code (c = attributes['code']).nil? ? nil : c.to_i end |
#code=(i) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
122 123 124 |
# File 'lib/agent_xmpp/xmpp/error_response.rb', line 122 def code=(i) attributes['code'] = i.nil? ? nil : i.to_s end |
#error ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
127 128 129 130 131 |
# File 'lib/agent_xmpp/xmpp/error_response.rb', line 127 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) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
134 135 136 137 138 139 140 141 |
# File 'lib/agent_xmpp/xmpp/error_response.rb', line 134 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 |
#text ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
144 145 146 |
# File 'lib/agent_xmpp/xmpp/error_response.rb', line 144 def text first_element_text('text') || super end |
#text=(s) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
149 150 151 152 153 154 155 156 |
# File 'lib/agent_xmpp/xmpp/error_response.rb', line 149 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 |