Due to John Papa - 10 AngularJS Patterns presentation advices I try to implement additional functionality to exception handling:
exceptionHandlerDecorator.$inject = ['$provide'];
function exceptionHandlerDecorator($provide){
$provide.decorator('$exceptionHandler', handleException);
}
handleException.$inject = ['$delegate', 'ExceptionHandlerService'];
function handleException($delegate, ExceptionHandlerService){
function handle(exception, cause){
$delegate(exception, cause);
ExceptionHandlerService.handle(exception.message);
}
return handle;
}
ExceptionHandlerService.$inject = ['$modal'];
function ExceptionHandlerService($modal){
//do things
}
But when I try ti inject $modal
to ExceptionHandlerService
from Angular UI Bootstrap I got Error: $injector:cdep Circular Dependency which terrified me. I tried to use accepted solution from very similar question, Injecting $http into angular factory($exceptionHandler) results in a Circular dependency:
function ExceptionHandlerService($window, $injector){
var $modal = $injector.get('$modal')
}
But it gave me exactly the same result - Error: $injector:cdep Circular Dependency
. Has anyone had similar problem and knows the solution? Thank you in advance for your attention.