Reputation: 8894
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
Upvotes: 3
Views: 813
Reputation: 5300
Judging from the source code of Jersey where this is handled there is no way to do this with an ExceptionMapper
. WebApplicationExceptions
get a special treatment are never mapped.
A way to log all exceptions is to set the logger org.glassfish.jersey.server.ServerRuntime
to FINER
.
Upvotes: 1