From 8991f4f900a74f402677b44cf63e46e169052ded Mon Sep 17 00:00:00 2001 From: Spencer Norman Date: Fri, 28 Oct 2016 17:57:39 -0600 Subject: [PATCH 1/2] Fixes #1537 - Alerts throwing error * catch errors thrown with lodash noop See https://github.com/limonte/sweetalert2/issues/177 --- .../layout/client/templates/layout/alerts/reactionAlerts.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/imports/plugins/core/layout/client/templates/layout/alerts/reactionAlerts.js b/imports/plugins/core/layout/client/templates/layout/alerts/reactionAlerts.js index 82c26e24937..cf282934895 100644 --- a/imports/plugins/core/layout/client/templates/layout/alerts/reactionAlerts.js +++ b/imports/plugins/core/layout/client/templates/layout/alerts/reactionAlerts.js @@ -70,7 +70,7 @@ Object.assign(Alerts, { if (isConfirm === true && typeof messageOrCallback === "function") { messageOrCallback(isConfirm); } - }); + }).catch(_.noop); } const title = titleOrOptions; @@ -85,7 +85,7 @@ Object.assign(Alerts, { if (isConfirm === true && typeof callback === "function") { callback(isConfirm); } - }); + }).catch(_.noop); }, toast(message, type, options) { From c36c1bdaa094b600294e119ddf86cb14a93300ec Mon Sep 17 00:00:00 2001 From: Spencer Norman Date: Mon, 31 Oct 2016 12:39:47 -0600 Subject: [PATCH 2/2] Don't blind catch sweet alert errors. --- .../templates/layout/alerts/reactionAlerts.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/imports/plugins/core/layout/client/templates/layout/alerts/reactionAlerts.js b/imports/plugins/core/layout/client/templates/layout/alerts/reactionAlerts.js index cf282934895..9d992c7c33a 100644 --- a/imports/plugins/core/layout/client/templates/layout/alerts/reactionAlerts.js +++ b/imports/plugins/core/layout/client/templates/layout/alerts/reactionAlerts.js @@ -70,7 +70,12 @@ Object.assign(Alerts, { if (isConfirm === true && typeof messageOrCallback === "function") { messageOrCallback(isConfirm); } - }).catch(_.noop); + }).catch(function (err) { + if (err === "cancel" || err === "overlay" || err === "timer") { + return undefined; // Silence error + } + throw err; + }); } const title = titleOrOptions; @@ -85,7 +90,12 @@ Object.assign(Alerts, { if (isConfirm === true && typeof callback === "function") { callback(isConfirm); } - }).catch(_.noop); + }).catch(function (err) { + if (err === "cancel" || err === "overlay" || err === "timer") { + return undefined; // Silence error + } + throw err; + }); }, toast(message, type, options) {