Hello,
I have a code which throws a specific type of exception like this:
throw new BadDataException("error message");
these kind of exceptions are thrown inside a method whose response type is json. I have a configuration for this exception type like this:
<global-exception-mappings>
<exception-mapping result="badDataError" exception="mypackage.BadDataException" />
</global-exception-mappings>
<result name="badDataError" type="json">
<param name="statusCode">500</param>
</result>
I'd like to add the exception message to the json response to show it to the user. Is there any way to map the exception message to the response when a 500 status code is returned. The ajax call would be something like this:
$.ajax(
{
...
success: function(data, textStatus) {
alert('Success');
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert("Error");//I'd like to add here the reason (exception message)
}
...
}
);
How can I add automatically the message of this exception to the HTTP 500 response? (if it is possible)
Thanks