I have code that throws a specific type of exception:
throw new BadDataException("error message");
these exceptions are thrown inside a method whose response type is json. I have a configuration for this type of exception, for example:
<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 would like to add an exception message in the json response to show it to the user. Is there a way to match the exception message with the response when the 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");
}
...
}
);
How can I automatically add a message about this exception to the HTTP 500 response? (if possible)
thank
source
share