Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Handle sendgrid bad request (#10949)

Tomasz Szymańskic27cc94d06ff
diff --git a/saleor/plugins/sendgrid/tasks.py b/saleor/plugins/sendgrid/tasks.py
index 056378fa43..23110ac45f 100644
--- a/saleor/plugins/sendgrid/tasks.py
+++ b/saleor/plugins/sendgrid/tasks.py
@@ -1,5 +1,6 @@
import logging
+from python_http_client import exceptions
from sendgrid import SendGridAPIClient, SendGridException
from sendgrid.helpers.mail import Mail
@@ -24,7 +25,10 @@ def send_email(configuration: SendgridConfiguration, template_id, payload):
message = Mail(from_email=from_email, to_emails=recipient_email)
message.dynamic_template_data = payload
message.template_id = template_id
- sendgrid_client.send(message)
+ try:
+ sendgrid_client.send(message)
+ except exceptions.BadRequestsError as e:
+ logger.warning("Bad request to Sendgrid, response: %s" % e.body)
@app.task(