5

In angularjs is it possible to add global exception handler at one place? So even if you miss to add exception handler for any code user will get a proper message. E.g Something went wrong.

6
  • wat type of exception are you talking about. ? Commented Dec 4, 2015 at 11:56
  • I created a services that handles error msgs if that is what you mean Commented Dec 4, 2015 at 11:56
  • @SajanChandran common way to handle all the javascript exception Commented Dec 4, 2015 at 11:58
  • @jax can you provide as a answer Commented Dec 4, 2015 at 11:58
  • there is no one common way to handle all javascript exceptions. Commented Dec 4, 2015 at 12:00

1 Answer 1

8
angular.module("app")
.factory("$exceptionHandler",  function() {
        return function (exception, cause) {
            //exception handling here
        };
    });

From here

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

6 Comments

Hey Costanza, explain your answers please!
I think it's pretty self-explanatory. The function body is the override for exception handling.
This is in the official docs, so either you are doing it wrong or you have a bug and you should file a bug report rather than downvoting my answer.
@R. Salisbury, Dont know why someone downvote you, so +1 for your answer, and indeed... Self Explanatory...
you've got an orphaned close bracket in the last line: ]
|

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.