From b4493155fc6aaf1273d3699312a153dada01ec07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 6 Jul 2016 06:41:39 +0200 Subject: [PATCH] fix(error handling): improved dashboard init error handling and notifications --- public/app/features/dashboard/dashboard_ctrl.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/public/app/features/dashboard/dashboard_ctrl.ts b/public/app/features/dashboard/dashboard_ctrl.ts index 6340c29724f..a286512f22c 100644 --- a/public/app/features/dashboard/dashboard_ctrl.ts +++ b/public/app/features/dashboard/dashboard_ctrl.ts @@ -54,15 +54,20 @@ export class DashboardCtrl { $scope.setWindowTitleAndTheme(); $scope.appEvent("dashboard-initialized", $scope.dashboard); - }).catch(function(err) { - if (err.data && err.data.message) { err.message = err.data.message; } - $scope.appEvent("alert-error", ['Dashboard init failed', 'Template variables could not be initialized: ' + err.message]); - }); + }).catch($scope.dashboardInitError.bind(this)); } catch (err) { - $scope.appEvent("alert-error", ['Dashboard init failed', err.message]); + $scope.dashboardInitError(err); } }; + $scope.dashboardInitError = function(err) { + console.log('Dashboard init failed', err); + if (err.data && err.data.message) { + err.message = err.data.message; + } + $scope.appEvent("alert-error", ['Dashboard init failed', err.message]); + }; + $scope.templateVariableUpdated = function() { dynamicDashboardSrv.update($scope.dashboard); };