diff --git a/lib/fog/aws/auto_scaling.rb b/lib/fog/aws/auto_scaling.rb index fd3b43764..dc42afbc1 100644 --- a/lib/fog/aws/auto_scaling.rb +++ b/lib/fog/aws/auto_scaling.rb @@ -151,7 +151,7 @@ module Fog :parser => parser }) rescue Excon::Errors::HTTPStatusError => error - if match = error.message.match(/(.*)<\/Code>.*(.*)<\/Message>/) + if match = error.message.match(/(?:.*(.*)<\/Code>)(?:.*(.*)<\/Message>)/m) case match[1] when 'AlreadyExists' #raise Fog::AWS::AutoScaling::IdentifierTaken.new(match[2]) diff --git a/lib/fog/aws/beanstalk.rb b/lib/fog/aws/beanstalk.rb index 0112d8deb..66a0f7d39 100644 --- a/lib/fog/aws/beanstalk.rb +++ b/lib/fog/aws/beanstalk.rb @@ -131,7 +131,7 @@ module Fog :parser => parser }) rescue Excon::Errors::HTTPStatusError => error - if match = error.response.body.match(/(.*)<\/Code>[ \t\n]*(.*)<\/Message>/) + if match = error.message.match(/(?:.*(.*)<\/Code>)(?:.*(.*)<\/Message>)/m) raise case match[1].split('.').last when 'InvalidParameterValue' Fog::AWS::ElasticBeanstalk::InvalidParameterError.slurp(error, match[2]) diff --git a/lib/fog/aws/cloud_formation.rb b/lib/fog/aws/cloud_formation.rb index a87acaa9d..c33e2ef08 100644 --- a/lib/fog/aws/cloud_formation.rb +++ b/lib/fog/aws/cloud_formation.rb @@ -106,7 +106,7 @@ module Fog :parser => parser }) rescue Excon::Errors::HTTPStatusError => error - if match = error.message.match(/(.*)<\/Code>(.*)<\/Message>/) + if match = error.message.match(/(?:.*(.*)<\/Code>)(?:.*(.*)<\/Message>)/m) raise case match[1].split('.').last when 'NotFound' Fog::AWS::Compute::NotFound.slurp(error, match[2]) diff --git a/lib/fog/aws/compute.rb b/lib/fog/aws/compute.rb index e221eefd8..b77a5075e 100644 --- a/lib/fog/aws/compute.rb +++ b/lib/fog/aws/compute.rb @@ -391,7 +391,7 @@ module Fog :parser => parser }) rescue Excon::Errors::HTTPStatusError => error - if match = error.message.match(/(.*)<\/Code>(.*)<\/Message>/) + if match = error.message.match(/(?:.*(.*)<\/Code>)(?:.*(.*)<\/Message>)/m) raise case match[1].split('.').last when 'NotFound', 'Unknown' Fog::Compute::AWS::NotFound.slurp(error, match[2]) diff --git a/lib/fog/aws/elasticache.rb b/lib/fog/aws/elasticache.rb index caa6f19f8..474dca6c4 100644 --- a/lib/fog/aws/elasticache.rb +++ b/lib/fog/aws/elasticache.rb @@ -104,7 +104,7 @@ module Fog :parser => parser }) rescue Excon::Errors::HTTPStatusError => error - if match = error.message.match(/(.*)<\/Code>/m) + if match = error.message.match(/(?:.*(.*)<\/Code>?)/m) case match[1] when 'CacheSecurityGroupNotFound', 'CacheParameterGroupNotFound', 'CacheClusterNotFound' diff --git a/lib/fog/aws/elb.rb b/lib/fog/aws/elb.rb index 2518d0653..9e529dc1e 100644 --- a/lib/fog/aws/elb.rb +++ b/lib/fog/aws/elb.rb @@ -191,7 +191,7 @@ module Fog :parser => parser }) rescue Excon::Errors::HTTPStatusError => error - if match = error.message.match(/(.*)<\/Code>(?:.*(.*)<\/Message>)?/m) + if match = error.message.match(/(?:.*(.*)<\/Code>)(?:.*(.*)<\/Message>)/m) case match[1] when 'CertificateNotFound' raise Fog::AWS::IAM::NotFound.slurp(error, match[2]) diff --git a/lib/fog/aws/iam.rb b/lib/fog/aws/iam.rb index 7bd88ef16..8cbe558d7 100644 --- a/lib/fog/aws/iam.rb +++ b/lib/fog/aws/iam.rb @@ -205,7 +205,7 @@ module Fog :parser => parser }) rescue Excon::Errors::HTTPStatusError => error - if match = error.message.match(/(.*)<\/Code>(?:.*(.*)<\/Message>)?/m) + if match = error.message.match(/(?:.*(.*)<\/Code>)(?:.*(.*)<\/Message>)/m) case match[1] when 'CertificateNotFound', 'NoSuchEntity' raise Fog::AWS::IAM::NotFound.slurp(error, match[2]) diff --git a/lib/fog/aws/rds.rb b/lib/fog/aws/rds.rb index 48912b2ed..c1dde6f2d 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>[\s\\\w]+(.*)<\/Message>/m) + if match = error.message.match(/(?:.*(.*)<\/Code>)(?:.*(.*)<\/Message>)/m) case match[1].split('.').last when 'DBInstanceNotFound', 'DBParameterGroupNotFound', 'DBSnapshotNotFound', 'DBSecurityGroupNotFound' raise Fog::AWS::RDS::NotFound.slurp(error, match[2]) diff --git a/lib/fog/aws/sts.rb b/lib/fog/aws/sts.rb index 3e3084db4..22248b1c0 100644 --- a/lib/fog/aws/sts.rb +++ b/lib/fog/aws/sts.rb @@ -114,7 +114,7 @@ module Fog response rescue Excon::Errors::HTTPStatusError => error - if match = error.message.match(/(.*)<\/Code>(?:.*(.*)<\/Message>)?/m) + if match = error.message.match(/(?:.*(.*)<\/Code>)(?:.*(.*)<\/Message>)/m) case match[1] when 'EntityAlreadyExists', 'KeyPairMismatch', 'LimitExceeded', 'MalformedCertificate', 'ValidationError' raise Fog::AWS::STS.const_get(match[1]).slurp(error, match[2])