Skip to content

Commit 8ddee9b

Browse files
committed
add $exceptionHandler service
1 parent a161a99 commit 8ddee9b

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

src/services.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ angularService("$log", function($window){
7575
};
7676
}, {inject:['$window']});
7777

78+
angularService('$exceptionHandler', function($log){
79+
return function(e) {
80+
$log.error(e);
81+
};
82+
}, {inject:['$log']});
83+
7884
angularService("$hover", function(browser, document) {
7985
var tooltip, self = this, error, width = 300, arrowWidth = 10, body = jqLite(document[0].body);;
8086
browser.hover(function(element, show){

test/servicesSpec.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,15 @@ describe("service", function(){
6666
});
6767
});
6868

69+
describe("$exceptionHandler", function(){
70+
it('should log errors', function(){
71+
var error = '';
72+
$log.error = function(m) { error += m; };
73+
scope.$exceptionHandler('myError');
74+
expect(error).toEqual('myError');
75+
});
76+
});
77+
6978
describe("$location", function(){
7079
it("should inject $location", function(){
7180
scope.$location.parse('http://host:123/p/a/t/h.html?query=value#path?key=value');

0 commit comments

Comments
 (0)