From 15546dd84e871299b1eea3fea5c768c243395447 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Sat, 9 Jan 2016 19:14:59 +0100 Subject: [PATCH] feat(plugins): added better error message when trying to load data source plugin module that is missing datasource constructor --- public/app/core/services/alert_srv.js | 4 ++++ public/app/core/services/datasource_srv.js | 7 +++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/public/app/core/services/alert_srv.js b/public/app/core/services/alert_srv.js index cecc8eadadf..463be459659 100644 --- a/public/app/core/services/alert_srv.js +++ b/public/app/core/services/alert_srv.js @@ -46,6 +46,10 @@ function (angular, _, coreModule) { }, timeout); } + if (!$rootScope.$$phase) { + $rootScope.$digest(); + } + return(newAlert); }; diff --git a/public/app/core/services/datasource_srv.js b/public/app/core/services/datasource_srv.js index 1f2b492ee93..07e3f004d45 100644 --- a/public/app/core/services/datasource_srv.js +++ b/public/app/core/services/datasource_srv.js @@ -7,7 +7,7 @@ define([ function (angular, _, coreModule, config) { 'use strict'; - coreModule.default.service('datasourceSrv', function($q, $injector) { + coreModule.default.service('datasourceSrv', function($q, $injector, $rootScope) { var self = this; this.init = function() { @@ -60,7 +60,6 @@ function (angular, _, coreModule, config) { var deferred = $q.defer(); var pluginDef = dsConfig.meta; - console.log(pluginDef); System.import(pluginDef.module).then(function(plugin) { // check if its in cache now if (self.datasources[name]) { @@ -70,7 +69,7 @@ function (angular, _, coreModule, config) { // plugin module needs to export a constructor function named Datasource if (!plugin.Datasource) { - return; + throw "Plugin module is missing Datasource constructor"; } var instance = $injector.instantiate(plugin.Datasource, {instanceSettings: dsConfig}); @@ -79,7 +78,7 @@ function (angular, _, coreModule, config) { self.datasources[name] = instance; deferred.resolve(instance); }).catch(function(err) { - console.log('Failed to load data source: ' + err); + $rootScope.appEvent('alert-error', [dsConfig.name + ' plugin failed', err.toString()]); }); return deferred.promise;