When calling a REST Service from angularjs, when an Exception is thrown it
returning full java stack trace under data object of error function.
I also tried to create a new Exception object from java service with
custom message but still its same issue.
How to display only the error messages on REST service call errors?
(It should show only the message "Custom error message")
Here is my angular configuration snippet:
The error popup shows full HTML text with java stack trace.
}).error(function(data){
alert(data);
$location.path("/");
});
Here is REST Service
@POST
@Path(value = "/getDetails")
@RequestMapping(value = "/getDetails", method = RequestMethod.POST,
headers = "Accept=application/json; charset=UTF-8")
@ResponseStatus(value = HttpStatus.OK)
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
@ResponseBody
@SuppressWarnings("rawtypes")
public String getDetails(...) throws Exception {
...
catch(Exception customError) {
log.error("Custom error message");
throw new Exception("Custom error message");
} ...}
--
You received this message because you are subscribed to the Google Groups
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.