Andremoniy
Andremoniy

Reputation: 34920

How to add headers to HTTP response within ClientErrorException?

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?

Upvotes: 0

Views: 638

Answers (1)

metodski
metodski

Reputation: 555

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

Upvotes: 2

Related Questions