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:
parent
a5d39f73d8
commit
d8c3223e79
1 changed files with 22 additions and 9 deletions
|
@ -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,6 +105,7 @@ module Fog
|
|||
end
|
||||
body.chop! # remove trailing '&'
|
||||
|
||||
begin
|
||||
response = @connection.request({
|
||||
:body => body,
|
||||
:expects => 200,
|
||||
|
@ -112,6 +115,16 @@ module Fog
|
|||
: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
|
||||
|
|
Loading…
Add table
Reference in a new issue