I am trying to learn AngularJS by building a small webapp with Spring MVC-Spring Security-AngularJS. My UserDetailsService throws a UserNotFoundException while logging in. But i don't know how to handle exceptions in Angular. I have tried to google but could not find simple, complete examples about exception handling.
This is a part of my authentication angular module:
$http.get('user', {
headers : headers
}).success(function(data) {
if (data.name) {
auth.authenticated = true;
} else {
auth.authenticated = false;
}
callback && callback(auth.authenticated);
$location.path(auth.path==auth.loginPath ? auth.homePath : auth.path);
}).error(function() {
auth.authenticated = false;
callback && callback(false);
});
How can i reach and catch this specific UserNotFoundException inside the error callback function?