Exception: DynamicsCRM::XML::Fault
- Inherits:
-
RuntimeError
- Object
- RuntimeError
- DynamicsCRM::XML::Fault
- Defined in:
- lib/dynamics_crm/xml/fault.rb
Overview
Represents a SOAP Fault Resposible for parsing each element
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#detail ⇒ Object
readonly
Returns the value of attribute detail.
-
#reason ⇒ Object
readonly
Returns the value of attribute reason.
-
#subcode ⇒ Object
readonly
Returns the value of attribute subcode.
Instance Method Summary collapse
-
#initialize(fault_xml) ⇒ Fault
constructor
A new instance of Fault.
- #message ⇒ Object
Constructor Details
#initialize(fault_xml) ⇒ Fault
Returns a new instance of Fault.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/dynamics_crm/xml/fault.rb', line 10 def initialize(fault_xml) if fault_xml.is_a?(Array) fault_xml = fault_xml.first end # REXL::Element @code = fault_xml.get_text("//[local-name() = 'Code']/[local-name() = 'Value']") @subcode = fault_xml.get_text("//[local-name() = 'Code']/[local-name() = 'Subcode']/[local-name() = 'Value']") @reason = fault_xml.get_text("//[local-name() = 'Reason']/[local-name() = 'Text']") @detail = {} detail_fragment = fault_xml.get_elements("//[local-name() = 'Detail']").first if detail_fragment fault_type = detail_fragment.elements.first @detail[:type] = fault_type.name detail_fragment.elements.first.each_element do |node| @detail[node.name.to_sym] = node.text end end end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
8 9 10 |
# File 'lib/dynamics_crm/xml/fault.rb', line 8 def code @code end |
#detail ⇒ Object (readonly)
Returns the value of attribute detail.
8 9 10 |
# File 'lib/dynamics_crm/xml/fault.rb', line 8 def detail @detail end |
#reason ⇒ Object (readonly)
Returns the value of attribute reason.
8 9 10 |
# File 'lib/dynamics_crm/xml/fault.rb', line 8 def reason @reason end |
#subcode ⇒ Object (readonly)
Returns the value of attribute subcode.
8 9 10 |
# File 'lib/dynamics_crm/xml/fault.rb', line 8 def subcode @subcode end |
Instance Method Details
#message ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/dynamics_crm/xml/fault.rb', line 31 def if @detail.empty? "%s[%s] %s" % [@code, @subcode, @reason] else "%s[%s] %s (Detail => %s)" % [@code, @subcode, @reason, @detail] end end |