users@jersey.java.net

Re: [Jersey] Catching and representing exceptions

From: Alexandru Popescu ☀ <the.mindstorm.mailinglist_at_gmail.com>
Date: Fri, 3 Sep 2010 12:27:48 +0300

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?

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