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.
-
try catch does not have a performance hit, it is a mechanism for catching errors.SoluableNonagon– SoluableNonagon2014-07-29 16:45:39 +00:00Commented Jul 29, 2014 at 16:45
-
try { someFunction() } catch(error){ console.log(error); }SoluableNonagon– SoluableNonagon2014-07-29 16:46:19 +00:00Commented Jul 29, 2014 at 16:46
Add a comment
|
1 Answer
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);
};
});
});
1 Comment
harishr
It's just add it's to an error array, what to do with array is your decision