users@jersey.java.net

RE: [Jersey] Invoking ExceptionMapper within ExceptionMapper

From: Markus Karg <karg_at_quipsy.de>
Date: Mon, 6 Apr 2009 09:49:06 +0200

Paul,

 

thank you very much. Once more this proofs how easily I forget things I
already knew before if not using them every day. ;-)

 

Thanks

Markus

 

From: Paul.Sandoz_at_Sun.COM [mailto:Paul.Sandoz_at_Sun.COM]
Sent: Freitag, 3. April 2009 15:46
To: users_at_jersey.dev.java.net
Subject: Re: [Jersey] Invoking ExceptionMapper within ExceptionMapper

 

 

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.