I am new to angularjs. I am using angularjs 1.4 version. I am attempting to handle exception which is throwing from Spring controller method. But i could not able to catch the exception in below js below.
May be this is duplicate question, but i had searched solution in SO. But did not work. Please give me suggestion for this. Thanks in advance.
Also throwing exceptions in Spring MVC controller method is correct? or how to say 500 error to front end?
In Angular Controller:
Service.calculate (obj).then(function(response){
// logic
});
In Angular Service:
this.calculate = function(obj){
try {
return $http.post(PATH+'txn/calc',obj).then(function(resp){
return resp;
});
} catch (e) {
alert(e);
}
};
Spring controller method :
@RequestMapping(value = "/txn/calc", method = RequestMethod.POST)
public @ResponseBody someBean calculate(@RequestBody SomeBean someBean , HttpServletRequest request) {
try {
// exception occurs here
} catch (Exception e) {
throw e;
}
}