0

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.

2
  • try catch does not have a performance hit, it is a mechanism for catching errors. Commented Jul 29, 2014 at 16:45
  • try { someFunction() } catch(error){ console.log(error); } Commented Jul 29, 2014 at 16:46

1 Answer 1

1

if you want to handle try/catch better or handle exception and keep the log of them write a decorate around angularjs exception handler

example here

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);
        };
    });

});
Sign up to request clarification or add additional context in comments.

1 Comment

It's just add it's to an error array, what to do with array is your decision

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.