From 29a505464583bf0b6d3d88f73b1b4fdd251b1a8c Mon Sep 17 00:00:00 2001
From: Lewis Liu <develop@lewisl.net>
Date: Tue, 28 Jun 2016 13:55:21 -0700
Subject: [PATCH] Added error handling for dashboard cards

---
 frontend/src/metabase/dashboard/dashboard.js | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/frontend/src/metabase/dashboard/dashboard.js b/frontend/src/metabase/dashboard/dashboard.js
index a27ebc1bc91..f9c775012df 100644
--- a/frontend/src/metabase/dashboard/dashboard.js
+++ b/frontend/src/metabase/dashboard/dashboard.js
@@ -152,7 +152,23 @@ export const fetchCardData = createThunkAction(FETCH_CARD_DATA, function(card, d
             }
         }, DATASET_SLOW_TIMEOUT);
 
-        result = await MetabaseApi.dataset(datasetQuery);
+
+        try {
+          // result = await MetabaseApi.dataset(datasetQuery);
+          // mocking an angular $http response 504 object
+          // not sure if this is the exact shape and content, but hopefully close enough
+          result = await Promise.reject({
+            status: 504,
+            statusText: "GATEWAY_TIMEOUT",
+            data: {
+              message: "Failed to load resource: the server responded with a status of 504 (GATEWAY_TIMEOUT)"
+            }
+          });
+        }
+        catch (error) {
+          clearTimeout(slowCardTimer);
+          return { dashcard_id: dashcard.id, card_id: card.id, result: { error } };
+        }
 
         clearTimeout(slowCardTimer);
         return { dashcard_id: dashcard.id, card_id: card.id, result };
-- 
GitLab