-
Notifications
You must be signed in to change notification settings - Fork 92
Expand file tree
/
Copy patherrorReporter.js
More file actions
executable file
·44 lines (40 loc) · 1.28 KB
/
Copy patherrorReporter.js
File metadata and controls
executable file
·44 lines (40 loc) · 1.28 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
angular.module("proton.errorReporter", [])
.factory("errorReporter", function($log, $rootScope, $q, notify) {
var api = _.bindAll({
catcher: function(msg, promise) {
var self = this;
return function(error) {
self.notify(msg, error);
if (promise) {
promise.reject();
}
};
},
resolve: function(msg, promise, defaultResult) {
var q = $q.defer();
var self = this;
promise.then(
function(result) {
q.resolve(result);
},
function(error) {
self.notify(msg, error);
q.resolve(defaultResult);
}
);
return q.promise;
},
notify: function(message, error) {
if (angular.isDefined(message)) {
notify(message);
}
},
clear: function() {
notify.closeAll();
}
});
return api;
})
.run(function($rootScope) {
$rootScope.errorReporter = {};
});