I have a custom ClientErrorException
and I want to add some specific headers to the response when this exception is thrown.
For example, I can specify status of the response in the constructor:
public ClientErrorException(String message, Response.Status status) {
...
}
But how to specify headers? What the proper way to do that?
You can use an ExceptionMapper for jax-rs to return a custom response when an exception is thrown.
There is a nice example in here