I want my ExceptionMapper to catch all exceptions and log them... I'm using Jersey 2.0 right now.
I have an exception mapper like so:
@Provider
public class RestExceptionMapper implements ExceptionMapper<Exception> {
@Override
public Response toResponse(Exception e) {
log(e);
if (e instanceof WebApplicationException) {
return ((WebApplicationException) e).getResponse();
} else {
return buildResponse(e);
}
This exception mapper only gets called for non-WebApplication application exceptions.
How do I make one global exception mapper catch all the exceptions so I can log them. Is there another way I should approach this?
Thanks
WebApplicationException
. Seems it was fixed somewhere between 2.0 and 2.16 and this question is no longer relevant. – Oleg Estekhin