Exception: OpenBuildServiceAPI::RemoteAPIError

Inherits:
Exception
  • Object
show all
Defined in:
lib/exception.rb

Overview

remote API network errors

Instance Attribute Summary collapse

Instance Method Summary collapse

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, message=nil)
  response_body = response.body

  @response = response
  @message = message ? message : 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_codeObject

Returns the value of attribute error_code.



4
5
6
# File 'lib/exception.rb', line 4

def error_code
  @error_code
end

#error_summaryObject

Returns the value of attribute error_summary.



4
5
6
# File 'lib/exception.rb', line 4

def error_summary
  @error_summary
end

#messageObject

Returns the value of attribute message.



4
5
6
# File 'lib/exception.rb', line 4

def message
  @message
end

#responseObject

Returns the value of attribute response.



4
5
6
# File 'lib/exception.rb', line 4

def response
  @response
end

Instance Method Details

#to_sObject



23
24
25
# File 'lib/exception.rb', line 23

def to_s
  @message
end