users@jersey.java.net

Re: [Jersey] Catching and representing exceptions

From: Paul Sandoz <Paul.Sandoz_at_oracle.com>
Date: Fri, 3 Sep 2010 11:51:19 +0200

On Sep 3, 2010, at 11:27 AM, Alexandru Popescu ☀ wrote:

> On Thu, Sep 2, 2010 at 4:10 PM, Paul Sandoz <Paul.Sandoz_at_oracle.com>
> wrote:
>>
>> 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.
>
> How angry would get everyone if I suggest again my proposal?
>

I won't :-) I would like to add that proposal as a recommended pattern
to the Jersey user guide.

Paul.

> http://jots.mypopescu.com/post/1031879539/my-experience-with-jersey-jax-rs
>
> Summarized:
>
> - a custom entity that contains details about server side errors and
> can be served back to client in multiple formats according to the
> negotiated content type (currently it supports: html, json, xml)
>
> - 3 ExceptionMappers (dealing with WebApplicationException, Throwable,
> and a custom service specific super exception)
>
> :- alex
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>