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.
-
wat type of exception are you talking about. ?Sajan Chandran– Sajan Chandran2015-12-04 11:56:42 +00:00Commented Dec 4, 2015 at 11:56
-
I created a services that handles error msgs if that is what you meanJax– Jax2015-12-04 11:56:54 +00:00Commented Dec 4, 2015 at 11:56
-
@SajanChandran common way to handle all the javascript exceptionAnand Gargate– Anand Gargate2015-12-04 11:58:01 +00:00Commented Dec 4, 2015 at 11:58
-
@jax can you provide as a answerAnand Gargate– Anand Gargate2015-12-04 11:58:31 +00:00Commented Dec 4, 2015 at 11:58
-
there is no one common way to handle all javascript exceptions.Sajan Chandran– Sajan Chandran2015-12-04 12:00:54 +00:00Commented Dec 4, 2015 at 12:00
|
Show 1 more comment
1 Answer
angular.module("app")
.factory("$exceptionHandler", function() {
return function (exception, cause) {
//exception handling here
};
});
From here
6 Comments
Sterling Archer
Hey Costanza, explain your answers please!
R. Salisbury
I think it's pretty self-explanatory. The function body is the override for exception handling.
R. Salisbury
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.
Rogerio Soares
@R. Salisbury, Dont know why someone downvote you, so +1 for your answer, and indeed... Self Explanatory...
jbd
you've got an orphaned close bracket in the last line: ]
|