users@jersey.java.net

Re: [Jersey] Catching and representing exceptions

From: Paul Sandoz <Paul.Sandoz_at_oracle.com>
Date: Fri, 3 Sep 2010 12:05:39 +0200

On Sep 3, 2010, at 12:00 PM, Alexandru Popescu ☀ wrote:

> On Fri, Sep 3, 2010 at 12:51 PM, Paul Sandoz
> <Paul.Sandoz_at_oracle.com> wrote:
>>
>> 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.
>
> That would be awesome! I don't want to get (again) into the whole
> licensing/IP/thing, so what I'm planning to do is to upload this code
> on GitHub with a very liberal license. Even if people will not use it
> will be a reference for everyone. Will that work for you?
>

Yes, i think so.

Thanks,
Paul.