aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMisko Hevery2010-07-26 16:11:25 -0700
committerMisko Hevery2010-07-26 16:11:25 -0700
commit8ddee9bb25ade2bbe7d57db6353b29867606c184 (patch)
treef7c98bd303ba1e17f7d0835134fe2fdeb0823e62
parenta161a99ff8adfdf91202768950c6cddc93bf3101 (diff)
downloadangular.js-8ddee9bb25ade2bbe7d57db6353b29867606c184.tar.bz2
add $exceptionHandler service
-rw-r--r--src/services.js6
-rw-r--r--test/servicesSpec.js9
2 files changed, 15 insertions, 0 deletions
diff --git a/src/services.js b/src/services.js
index 89cca6fc..106f8954 100644
--- a/src/services.js
+++ b/src/services.js
@@ -75,6 +75,12 @@ angularService("$log", function($window){
};
}, {inject:['$window']});
+angularService('$exceptionHandler', function($log){
+ return function(e) {
+ $log.error(e);
+ };
+}, {inject:['$log']});
+
angularService("$hover", function(browser, document) {
var tooltip, self = this, error, width = 300, arrowWidth = 10, body = jqLite(document[0].body);;
browser.hover(function(element, show){
diff --git a/test/servicesSpec.js b/test/servicesSpec.js
index 031c48f0..91538703 100644
--- a/test/servicesSpec.js
+++ b/test/servicesSpec.js
@@ -66,6 +66,15 @@ describe("service", function(){
});
});
+ describe("$exceptionHandler", function(){
+ it('should log errors', function(){
+ var error = '';
+ $log.error = function(m) { error += m; };
+ scope.$exceptionHandler('myError');
+ expect(error).toEqual('myError');
+ });
+ });
+
describe("$location", function(){
it("should inject $location", function(){
scope.$location.parse('http://host:123/p/a/t/h.html?query=value#path?key=value');