In a web controller I have an @ExceptionHandler implementation to handle a certain type of device exception I can get. It looks like this :
@ExceptionHandler(DeviceException.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ResponseBody
public void handleException(DeviceException ex) {
log.error("controller caught exception " + ex.getMessage());
return ex.getMessage();
}
What I want to achieve is to have this return the Exception's message when a DeviceException is thrown.
On the client side I have this jQuery code, current problem is I can't seem to get any of the ex.getMessage() content in the error callback, that's what I need to solve.
$.ajax( {
type: "GET",
url: "<c:url value="/x/y/status"/>.json",
dataType: "json",
cache: false,
success: function ( data ){
// use the data
},
error: function(jqXHR, textStatus, errorThrown) {
// problem : all 3 of the data below (responseText etc.) are blank when I've thrown a DeviceException
alert('jqXHR.responseText = ', jqXHR.responseText);
alert('textStatus = ', textStatus);
alert('errorThrown = ', errorThrown);
}
} );