Reputation: 58
I am not sure whether try/catch is performance hit or not I want to use it in one of my AngularJs application. Will you please navigate me to right direction.
Upvotes: 0
Views: 3967
Reputation: 18055
if you want to handle try/catch better or handle exception and keep the log of them write a decorate around angularjs exception handler
app.config(function($provide){
$provide.decorator("$exceptionHandler", function($delegate, $injector){
return function(exception, cause){
var $rootScope = $injector.get("$rootScope");
$rootScope.addError({message:"Exception", reason:exception});
$delegate(exception, cause);
};
});
});
Upvotes: 1