forked from angular-app/angular-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexceptionHandler.js
More file actions
27 lines (22 loc) · 1.01 KB
/
Copy pathexceptionHandler.js
File metadata and controls
27 lines (22 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
angular.module('services.exceptionHandler', ['services.i18nNotifications']);
angular.module('services.exceptionHandler').factory('exceptionHandlerFactory', ['$injector', function($injector) {
return function($delegate) {
return function (exception, cause) {
// Lazy load notifications to get around circular dependency
//Circular dependency: $rootScope <- notifications <- i18nNotifications <- $exceptionHandler
var i18nNotifications = $injector.get('i18nNotifications');
// Pass through to original handler
$delegate(exception, cause);
// Push a notification error
i18nNotifications.pushForCurrentRoute('error.fatal', 'error', {}, {
exception:exception,
cause:cause
});
};
};
}]);
angular.module('services.exceptionHandler').config(['$provide', function($provide) {
$provide.decorator('$exceptionHandler', ['$delegate', 'exceptionHandlerFactory', function ($delegate, exceptionHandlerFactory) {
return exceptionHandlerFactory($delegate);
}]);
}]);