From 7b1ff9637eaea5ce27b5b6e9243cac3894b3fc8d Mon Sep 17 00:00:00 2001
From: Cam Saul <cammsaul@gmail.com>
Date: Mon, 16 Jul 2018 13:47:29 -0700
Subject: [PATCH] If sending a Slack pulse/alert fails, still send email
 pulse/alert (#7409)

---
 src/metabase/pulse.clj | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/metabase/pulse.clj b/src/metabase/pulse.clj
index 96a16402d46..aa2d7f8d484 100644
--- a/src/metabase/pulse.clj
+++ b/src/metabase/pulse.clj
@@ -15,8 +15,7 @@
             [metabase.util
              [ui-logic :as ui]
              [urls :as urls]]
-            [metabase.util.urls :as urls]
-            [puppetlabs.i18n.core :refer [tru]]
+            [puppetlabs.i18n.core :refer [trs tru]]
             [schema.core :as s]
             [toucan.db :as db])
   (:import java.util.TimeZone
@@ -212,7 +211,12 @@
 
 (defn- send-notifications! [notifications]
   (doseq [notification notifications]
-    (send-notification! notification)))
+    ;; do a try-catch around each notification so if one fails, we'll still send the other ones for example, an Alert
+    ;; set up to send over both Slack & email: if Slack fails, we still want to send the email (#7409)
+    (try
+      (send-notification! notification)
+      (catch Throwable e
+        (log/error e (trs "Error sending notification!"))))))
 
 (defn- pulse->notifications [{:keys [cards channel-ids], :as pulse}]
   (let [results     (for [card  cards
-- 
GitLab