Exception: OpenBuildServiceAPI::RemoteAPIError
- Inherits:
-
Exception
- Object
- Exception
- OpenBuildServiceAPI::RemoteAPIError
- Defined in:
- lib/exception.rb
Overview
remote API network errors
Direct Known Subclasses
Instance Attribute Summary collapse
-
#error_code ⇒ Object
Returns the value of attribute error_code.
-
#error_summary ⇒ Object
Returns the value of attribute error_summary.
-
#message ⇒ Object
Returns the value of attribute message.
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
-
#initialize(response, message = nil) ⇒ RemoteAPIError
constructor
A new instance of RemoteAPIError.
- #to_s ⇒ Object
Constructor Details
#initialize(response, message = nil) ⇒ RemoteAPIError
Returns a new instance of RemoteAPIError.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/exception.rb', line 6 def initialize(response, =nil) response_body = response.body @response = response = ? : response_body response_xml = Nokogiri::XML(response_body) status = response_xml.xpath('./status')[0] if status @error_code = status.attr('code') summary = status.xpath('./summary') @error_summary = summary.text if summary[0] end end |
Instance Attribute Details
#error_code ⇒ Object
Returns the value of attribute error_code.
4 5 6 |
# File 'lib/exception.rb', line 4 def error_code @error_code end |
#error_summary ⇒ Object
Returns the value of attribute error_summary.
4 5 6 |
# File 'lib/exception.rb', line 4 def error_summary @error_summary end |
#message ⇒ Object
Returns the value of attribute message.
4 5 6 |
# File 'lib/exception.rb', line 4 def end |
#response ⇒ Object
Returns the value of attribute response.
4 5 6 |
# File 'lib/exception.rb', line 4 def response @response end |
Instance Method Details
#to_s ⇒ Object
23 24 25 |
# File 'lib/exception.rb', line 23 def to_s end |