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

Merge pull request #442 from bgentry/refactor_elb_error_handling

[aws|elb] Refactor ELB error handling
This commit is contained in:
Wesley Beary 2011-07-19 11:41:35 -07:00
commit b3b446f0b6
3 changed files with 23 additions and 42 deletions

View file

@ -144,34 +144,33 @@ module Fog
:version => '2011-04-05'
}
)
begin
response = @connection.request({
:body => body,
:expects => 200,
:headers => { 'Content-Type' => 'application/x-www-form-urlencoded' },
:idempotent => idempotent,
:host => @host,
:method => 'POST',
:parser => parser
})
rescue Excon::Errors::HTTPStatusError => error
if match = error.message.match(/<Code>(.*)<\/Code>/m)
case match[1]
when 'LoadBalancerNotFound'
raise Fog::AWS::ELB::NotFound
when 'DuplicateLoadBalancerName'
raise Fog::AWS::ELB::IdentifierTaken
when 'InvalidInstance'
raise Fog::AWS::ELB::InvalidInstance
else
raise
end
response = @connection.request({
:body => body,
:expects => 200,
:headers => { 'Content-Type' => 'application/x-www-form-urlencoded' },
:idempotent => idempotent,
:host => @host,
:method => 'POST',
:parser => parser
})
rescue Excon::Errors::HTTPStatusError => error
if match = error.message.match(/<Code>(.*)<\/Code>(?:.*<Message>(.*)<\/Message>)?/m)
case match[1]
when 'CertificateNotFound'
raise Fog::AWS::IAM::NotFound.slurp(error, match[2])
when 'LoadBalancerNotFound'
raise Fog::AWS::ELB::NotFound.slurp(error, match[2])
when 'DuplicateLoadBalancerName'
raise Fog::AWS::ELB::IdentifierTaken.slurp(error, match[2])
when 'InvalidInstance'
raise Fog::AWS::ELB::InvalidInstance.slurp(error, match[2])
else
raise
end
else
raise
end
response
end
end
end

View file

@ -46,15 +46,6 @@ module Fog
'LoadBalancerName' => lb_name,
:parser => Fog::Parsers::AWS::ELB::CreateLoadBalancer.new
}.merge!(params))
rescue Excon::Errors::HTTPStatusError => error
if match = error.message.match(/<Code>(.*)<\/Code>(?:.*<Message>(.*)<\/Message>)?/m)
case match[1]
when 'CertificateNotFound'
raise Fog::AWS::IAM::NotFound.slurp(error, match[2])
else
raise
end
end
end
end

View file

@ -43,15 +43,6 @@ module Fog
'LoadBalancerName' => lb_name,
:parser => Fog::Parsers::AWS::ELB::Empty.new
}.merge!(params))
rescue Excon::Errors::HTTPStatusError => error
if match = error.message.match(/<Code>(.*)<\/Code>(?:.*<Message>(.*)<\/Message>)?/m)
case match[1]
when 'CertificateNotFound'
raise Fog::AWS::IAM::NotFound.slurp(error, match[2])
else
raise
end
end
end
end