users@jersey.java.net

[Jersey] handling error handling - standard way to populate headers with error detail?

From: phil swenson <phil.swenson_at_gmail.com>
Date: Fri, 11 Jul 2014 16:55:13 -0600

I see that when something goes wrong in a service call I can write code
something like:

throw new WebApplicationException(
        Response
          .status(Status.BAD_REQUEST)
          .entity("Couldn't parse date: " + dateAsString + " (" +
e.getMessage() + ")")
          .build()
      );


I’m a bit unclear on what “entity” means in this case. Is there a way
to populate specific header fields? I would like a “message” header
entry along with a “detail”. For example, I want error messages to
show in the “message” header, stack dumps in “detail”….


Thanks for any thoughts….