Class: RightScale::CloudApi::Parser::AWS::ResponseErrorV1
- Inherits:
-
Object
- Object
- RightScale::CloudApi::Parser::AWS::ResponseErrorV1
- Defined in:
- lib/cloud/aws/base/parsers/response_error.rb
Overview
AWS response error parser, case 1
Class Method Summary collapse
-
.parse(response, options = {}) ⇒ String
Parse HTTP error message from a response body.
Class Method Details
.parse(response, options = {}) ⇒ String
Parse HTTP error message from a response body
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/cloud/aws/base/parsers/response_error.rb', line 60 def self.parse(response, ={}) result = "#{response.code}: " body = response.body.to_s if response['content-type'].to_s[/xml/] || body[/\A<\?xml /] hash = Utils::get_xml_parser_class([:xml_parser]).parse(body) if hash["Response"] && hash["Response"]["Errors"] errors = hash["Response"]["Errors"]["Error"] errors = [ errors ] if errors.is_a?(Hash) result += errors.map{ |error| "#{error['Code']}: #{error['Message']}" }.join('; ') # Display a RequestId here result << " (RequestID: #{hash["Response"]["RequestID"]})" end else result << "#{body}" unless body._blank? end result end |