mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-23 11:37:38 +08:00
fix($injector): report circularity in circular dependency error message
Change the error message for a circular dependency to display the full circle back to the first service being instantiated, so that the problem is obvious. The previous message stopped one dependency short of the full circle. Changes the content of the cdep error message, which may be considered a breaking change. Closes #7500
This commit is contained in:
committed by
rodyhaddad
parent
82cd6b87f0
commit
14e797c1a1
@@ -724,7 +724,8 @@ function createInjector(modulesToLoad) {
|
||||
function getService(serviceName) {
|
||||
if (cache.hasOwnProperty(serviceName)) {
|
||||
if (cache[serviceName] === INSTANTIATING) {
|
||||
throw $injectorMinErr('cdep', 'Circular dependency found: {0}', path.join(' <- '));
|
||||
throw $injectorMinErr('cdep', 'Circular dependency found: {0}',
|
||||
serviceName + ' <- ' + path.join(' <- '));
|
||||
}
|
||||
return cache[serviceName];
|
||||
} else {
|
||||
|
||||
@@ -630,7 +630,7 @@ describe('injector', function() {
|
||||
$provide.factory('service', function(service){});
|
||||
return function(service) {};
|
||||
}]);
|
||||
}).toThrowMinErr('$injector', 'cdep', 'Circular dependency found: service');
|
||||
}).toThrowMinErr('$injector', 'cdep', 'Circular dependency found: service <- service');
|
||||
});
|
||||
|
||||
|
||||
@@ -641,7 +641,7 @@ describe('injector', function() {
|
||||
$provide.factory('b', function(a){});
|
||||
return function(a) {};
|
||||
}]);
|
||||
}).toThrowMinErr('$injector', 'cdep', 'Circular dependency found: b <- a');
|
||||
}).toThrowMinErr('$injector', 'cdep', 'Circular dependency found: a <- b <- a');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user