Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 545d22b

Browse files
teroparodyhaddad
authored andcommitted
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
1 parent 3de07aa commit 545d22b

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/auto/injector.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,8 @@ function createInjector(modulesToLoad, strictDi) {
749749
function getService(serviceName) {
750750
if (cache.hasOwnProperty(serviceName)) {
751751
if (cache[serviceName] === INSTANTIATING) {
752-
throw $injectorMinErr('cdep', 'Circular dependency found: {0}', path.join(' <- '));
752+
throw $injectorMinErr('cdep', 'Circular dependency found: {0}',
753+
serviceName + ' <- ' + path.join(' <- '));
753754
}
754755
return cache[serviceName];
755756
} else {

test/auto/injectorSpec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ describe('injector', function() {
656656
$provide.factory('service', function(service){});
657657
return function(service) {};
658658
}]);
659-
}).toThrowMinErr('$injector', 'cdep', 'Circular dependency found: service');
659+
}).toThrowMinErr('$injector', 'cdep', 'Circular dependency found: service <- service');
660660
});
661661

662662

@@ -667,7 +667,7 @@ describe('injector', function() {
667667
$provide.factory('b', function(a){});
668668
return function(a) {};
669669
}]);
670-
}).toThrowMinErr('$injector', 'cdep', 'Circular dependency found: b <- a');
670+
}).toThrowMinErr('$injector', 'cdep', 'Circular dependency found: a <- b <- a');
671671
});
672672

673673
});

0 commit comments

Comments
 (0)