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

[aws|elb] move ELB error handling related to certs to the ELB service instead of duplicating at the request level.

This commit is contained in:
Blake Gentry 2011-07-19 10:12:49 -07:00
parent f876ee28a4
commit dc094bd781
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
when 'DuplicateLoadBalancerName'
raise Fog::AWS::ELB::IdentifierTaken
when 'InvalidInstance'
raise Fog::AWS::ELB::InvalidInstance
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