1
0
Fork 0
mirror of https://github.com/fog/fog-aws.git synced 2022-11-09 13:50:52 -05:00
fog--fog-aws/lib/fog/aws/errors.rb
Paulo Henrique Lopes Ribeiro 722bbdfa45 Remove unecessary requires
2015-04-06 11:23:35 -03:00

14 lines
No EOL
460 B
Ruby

module Fog
module AWS
module Errors
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
end
end
end