users@jersey.java.net

Re: [Jersey] Catching and representing exceptions

From: Paul Sandoz <Paul.Sandoz_at_oracle.com>
Date: Thu, 2 Sep 2010 15:10:17 +0200

On Sep 1, 2010, at 11:00 PM, tofferliu wrote:

>
> Hi,
>
> Presently, I have a webservice filter which catches all the
> exceptions and
> reformats them into xml or json. Right now the representation it
> presents is
> inconsitent with what the representation jersey decides to present
> for the
> other request. How do I go about getting what representation jersey
> decides
> to present the user (xml, json, etc). Also is this the right way of
> doing
> things?
>

When you say "webservice filter" do you mean a servlet filter?

Once you go outside the Jersey environment it is a little tricky.

Have you tried registering and using an implementation of
ExceptionMapper<Throwable> ?

Paul.