Class: RightScale::CloudApi::Parser::ECS::ResponseError
- Inherits:
-
Object
- Object
- RightScale::CloudApi::Parser::ECS::ResponseError
- Defined in:
- lib/cloud/ecs/pa/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
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/cloud/ecs/pa/parsers/response_error.rb', line 64 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) top_key = hash.keys.first error = hash[top_key] && hash[top_key]["Error"] if error result << ('%s: %s' % [error['Code'], error['Message']]) result << (' (RequestID: %s)' % hash[top_key]['RequestId']) end else result << body unless body._blank? end result end |