From 33b1e1608007a3b69d410241bc44b8685845f4f8 Mon Sep 17 00:00:00 2001 From: Blake Gentry Date: Wed, 20 Jul 2011 16:08:51 -0700 Subject: [PATCH] [aws|iam] Simplify error handling code for errors with custom classes --- lib/fog/aws/iam.rb | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/lib/fog/aws/iam.rb b/lib/fog/aws/iam.rb index e39ad7c3a..aaf01fd18 100644 --- a/lib/fog/aws/iam.rb +++ b/lib/fog/aws/iam.rb @@ -156,16 +156,8 @@ module Fog case match[1] when 'CertificateNotFound', 'NoSuchEntity' raise Fog::AWS::IAM::NotFound.slurp(error, match[2]) - when 'EntityAlreadyExists' - raise Fog::AWS::IAM::EntityAlreadyExists.slurp(error, match[2]) - when 'KeyPairMismatch' - raise Fog::AWS::IAM::KeyPairMismatch.slurp(error, match[2]) - when 'LimitExceeded' - raise Fog::AWS::IAM::LimitExceeded.slurp(error, match[2]) - when 'MalformedCertificate' - raise Fog::AWS::IAM::MalformedCertificate.slurp(error, match[2]) - when 'ValidationError' - raise Fog::AWS::IAM::ValidationError.slurp(error, match[2]) + when 'EntityAlreadyExists', 'KeyPairMismatch', 'LimitExceeded', 'MalformedCertificate', 'ValidationError' + raise Fog::AWS::IAM.const_get(match[1]).slurp(error, match[2]) else raise Fog::AWS::IAM::Error.slurp(error, "#{match[1]} => #{match[2]}") if match[1] raise