From 00d27f023c1f1f5f25f155081770661535fe466a Mon Sep 17 00:00:00 2001 From: Shuhei Date: Fri, 27 Sep 2024 14:58:41 +0900 Subject: [PATCH] raise exceptions for 5XX errors from SendGrid --- lib/sendgrid_actionmailer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sendgrid_actionmailer.rb b/lib/sendgrid_actionmailer.rb index f4d6686..412e615 100644 --- a/lib/sendgrid_actionmailer.rb +++ b/lib/sendgrid_actionmailer.rb @@ -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