1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[AWS|RDS] Properly rescue NotFound exceptions

The following code

    Fog::AWS::RDS.new.servers.get('none_such_server')

now returns `nil` instead of

    Excon::Errors::NotFound: Expected(200) <=> Actual(404 Not Found)

This regressed with excon 0.22.0.
This commit is contained in:
Aaron Suggs 2013-06-04 11:40:27 -04:00
parent 5eebf7d760
commit 30dd43f1e8

View file

@ -206,7 +206,7 @@ module Fog
:parser => parser
})
rescue Excon::Errors::HTTPStatusError => error
if match = error.message.match(/(?:.*<Code>(.*)<\/Code>)(?:.*<Message>(.*)<\/Message>)/m)
if match = error.response.body.match(/(?:.*<Code>(.*)<\/Code>)(?:.*<Message>(.*)<\/Message>)/m)
case match[1].split('.').last
when 'DBInstanceNotFound', 'DBParameterGroupNotFound', 'DBSnapshotNotFound', 'DBSecurityGroupNotFound'
raise Fog::AWS::RDS::NotFound.slurp(error, match[2])