app.factory('$exceptionHandler', function() {
return function(exception, cause) {
exception.message += ' (caused by "' + cause + '")';
throw exception;
};
});
Is it possible to handle all the exception globally in angularJs using $exceptionHandler
without writing try
or throw
block?
What I want is even if I forget to write the try-catch
block for the statements like var a=1/0
, I want to handle it in the above code.