users@jersey.java.net

Re: [Jersey] Invoking ExceptionMapper within ExceptionMapper

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Fri, 03 Apr 2009 15:45:33 +0200

On Apr 3, 2009, at 2:29 PM, Markus Karg wrote:

> I wrote my own XYZException mapper. It returns different Responses
> regarding on its own decision. That works well.
>
> But in some cases, the XYZException is just a wrapper around another
> (unkown) exception, found in e.getCause().
>
> I'd like Jersey to check whether there is an exception mapper for
> the cause.
>
> How can this be done?
>

Inject:

   @Context Providers ps;

onto your exception mapper and call:

   ps.getExceptionMapper()

   https://jsr311.dev.java.net/nonav/javadoc/javax/ws/rs/ext/Providers.html
#getExceptionMapper(java.lang.Class)

Paul.