From 30dd43f1e8ddf50fdff8a4a0c9606d2931d2b59d Mon Sep 17 00:00:00 2001 From: Aaron Suggs Date: Tue, 4 Jun 2013 11:40:27 -0400 Subject: [PATCH] [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. --- lib/fog/aws/rds.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fog/aws/rds.rb b/lib/fog/aws/rds.rb index c1dde6f2d..2d6884cc8 100644 --- a/lib/fog/aws/rds.rb +++ b/lib/fog/aws/rds.rb @@ -206,7 +206,7 @@ module Fog :parser => parser }) rescue Excon::Errors::HTTPStatusError => error - if match = error.message.match(/(?:.*(.*)<\/Code>)(?:.*(.*)<\/Message>)/m) + if match = error.response.body.match(/(?:.*(.*)<\/Code>)(?:.*(.*)<\/Message>)/m) case match[1].split('.').last when 'DBInstanceNotFound', 'DBParameterGroupNotFound', 'DBSnapshotNotFound', 'DBSecurityGroupNotFound' raise Fog::AWS::RDS::NotFound.slurp(error, match[2])