Hi,
I m using Jersey 1.9 and I've written a RuntimeExceptionMapper to handle all
the application runtime exceptions, including Jersey' thrown as well.
public class RuntimeExceptionMapper implements
ExceptionMapper<RuntimeException> {
@Override
public Response toResponse(RuntimeException e) {
if(e instanceof WebApplicationException) {
return ((WebApplicationException) e).getResponse();
}
// handle other exceptions...
}
}
Even I m handling the exceptions, these response are forwarded to http
container (Tomcat, in my case) and the client is receiving the Tomcat
specific HTML response, where as I want the clients to receive only the
status code. I tried with 'null' entity, but it is not working.
return Response.fromResponse(((WebApplicationException)
e).getResponse()).entity(null).build();
If I set some non-null entity, the response is just the headers and the
entity (no Tomcat specific HTML).
return Response.fromResponse(((WebApplicationException)
e).getResponse()).entity("error").build();
Is this what the actual behaviour and if yes, can we change that behaviour?
Thanks,
ManiKanta G
twitter.com/ManiKantaG