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

Add basic error handling for Fog::AWS::SES.

This commit is contained in:
Postmodern 2013-07-03 17:32:45 -07:00
parent a5d39f73d8
commit d8c3223e79

View file

@ -5,6 +5,8 @@ module Fog
class SES < Fog::Service
extend Fog::AWS::CredentialFetcher::ServiceMethods
class MessageRejected < Fog::Errors::Error; end
requires :aws_access_key_id, :aws_secret_access_key
recognizes :region, :host, :path, :port, :scheme, :persistent, :use_iam_profile, :aws_session_token, :aws_credentials_expire_at
@ -103,15 +105,26 @@ module Fog
end
body.chop! # remove trailing '&'
response = @connection.request({
:body => body,
:expects => 200,
:headers => headers,
:idempotent => idempotent,
:host => @host,
:method => 'POST',
:parser => parser
})
begin
response = @connection.request({
:body => body,
:expects => 200,
:headers => headers,
:idempotent => idempotent,
:host => @host,
:method => 'POST',
:parser => parser
})
rescue Excon::Errors::HTTPStatusError => error
match = Fog::AWS::Errors.match_error(error)
raise if match.empty?
raise case match[:code]
when 'MessageRejected'
Fog::AWS::SES::MessageRejected.slurp(error, match[:message])
else
Fog::AWS::SES::Error.slurp(error, "#{match[:code]} => #{match[:message]}")
end
end
response
end