Commit 15546dd8 by Torkel Ödegaard

feat(plugins): added better error message when trying to load data source plugin…

feat(plugins): added better error message when trying to load data source plugin module that is missing datasource constructor
parent ca3405af
......@@ -46,6 +46,10 @@ function (angular, _, coreModule) {
}, timeout);
}
if (!$rootScope.$$phase) {
$rootScope.$digest();
}
return(newAlert);
};
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment