Hi Gustavo,
Just create an Exception mapper for WebApplicationException. Jersey with give the exception to the mapper that more closely matches the exception thrown. The way I do error handling is having a default mapper (that catches Throwables) and then adding mappers to specific exception if I need to handle them in a specific way.
Cheers,
Pedro
From: Gustavo Garcia [mailto:ggb_at_tokbox.com]
Sent: 01 July 2014 06:52
To: users_at_jersey.java.net
Subject: [Jersey] Avoiding HTML response on unexpected exceptions
What is the best way to avoid jersey returning a HTML response with the error when an unexpected exception happens (i.e NullPointerException) ?
I tried creating a ExceptionMapper for Exception and it works but it means that I loose the default exception mapping for javax.ws.rs.WebApplicationException exceptions that is also quite bad.
What are the best practices here?
Thx a lot