From 6b62184c07bb101b5557e2a70ecf417d0493f5c7 Mon Sep 17 00:00:00 2001
From: Tanner Prestegard <tanner.prestegard@ligo.org>
Date: Fri, 12 Apr 2019 14:10:48 -0500
Subject: [PATCH] Prevent email sending failure from breaking process

---
 gracedb/alerts/email.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/gracedb/alerts/email.py b/gracedb/alerts/email.py
index 0ffa1f3b7..c79aa8385 100644
--- a/gracedb/alerts/email.py
+++ b/gracedb/alerts/email.py
@@ -152,4 +152,10 @@ def issue_email_alerts(event_or_superevent, alert_type, recipients,
 
     # Send email messages
     backend = get_connection()
-    backend.send_messages(messages)
+    try:
+        backend.send_messages(messages)
+    except Exception as e:
+        # If there is a problem sending emails just log it and continue since
+        # email alerts aren't mission critical. But we log the information
+        # since we want to understand what is happening.
+        logger.error('Error sending email alerts: {e}'.format(e=e))
-- 
GitLab