Module: Fog::AWS::Errors

Defined in:
lib/fog/aws/core.rb

Class Method Summary collapse

Class Method Details

.match_error(error) ⇒ Object



319
320
321
322
323
324
325
326
# File 'lib/fog/aws/core.rb', line 319

def self.match_error(error)
  matcher = lambda {|s| s.match(/(?:.*<Code>(.*)<\/Code>)(?:.*<Message>(.*)<\/Message>)/m)}
  [error.message, error.response.body].each(&Proc.new {|s|
    match = matcher.call(s)
    return {:code => match[1].split('.').last, :message => match[2]} if match
  })
  {} # we did not match the message or response body
end