users@jersey.java.net

Re: [Jersey] Catching and representing exceptions

From: Alexandru Popescu ☀ <the.mindstorm.mailinglist_at_gmail.com>
Date: Fri, 3 Sep 2010 13:00:36 +0300

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?

:- alex

> 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
>
>
>