Skip to content

Commit

Permalink
raise exceptions for 5XX errors from SendGrid
Browse files Browse the repository at this point in the history
  • Loading branch information
hrtshu committed Sep 27, 2024
1 parent 135d244 commit 00d27f0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/sendgrid_actionmailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def add_tracking_settings(sendgrid_mail, mail)
def perform_send_request(email)
result = client.mail._('send').post(request_body: email.to_json) # ლ(ಠ益ಠლ) that API

if result.status_code && result.status_code.start_with?('4')
if result.status_code && (result.status_code.start_with?('4') || result.status_code.start_with?('5'))
full_message = "Sendgrid delivery failed with #{result.status_code}: #{result.body}"
settings[:raise_delivery_errors] ? raise(SendgridDeliveryError, full_message) : warn(full_message)
end
Expand Down

0 comments on commit 00d27f0

Please sign in to comment.