[jax-rs-spec users] Adding a getFailure method to ContainerResponseContext

From: Guillermo González de Agüero <>
Date: Wed, 12 Apr 2017 11:25:55 +0200


What I'm asking for was basically proposed on JAX_RS_SPEC-230 [1], but was
then deferred.

I propose to add a new "Throwable getFailure()" or an "Optional<Throwable>
getFailure()" method to the ContainerResponseContext class.

The main usecase for this is logging of handled exceptions. As it works
now, one can log request exceptions in two ways:
- Implement the logic on every ExceptionMapper. Not very reliable since the
container may already provide some mappers that you don't own. That means
the user has to provide mappers for every possible exceptions.
- For unhandled exceptions (not covered by any ExceptionMapper) and JAX-RS
working on top o a Servlet Container, they can be caught on a Servlet
filter. But that only works for the unhandled ones.

The addition of that method would simplify monitoring solutions that could
control failed requests at application level, instead of checking response
status. As of now, Jersey supports this via non-portable features [2].

I haven't opened a new issue since JAX_RS_SPEC-230 is already there asking
for the same thing. Should I open a new one?


Guillermo González de Agüero.