users@jersey.java.net

Re: [Jersey] Customize default error responses

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 03 Feb 2010 11:07:19 +0100

On Feb 2, 2010, at 8:23 PM, Robert Koberg wrote:

>
> On Feb 2, 2010, at 11:13 AM, Chris Carrier wrote:
>
>> The WebApplicationException contains the status. Something like:
>>
>> e.getResponse().getStatus()
>
>
> Sorry, I meant with the Throwable.
>

As Chris says that "catch-all" mapper could use the 500 status code,
but it is up to the application to do the mapping from the Throwable,
whereas for WebApplicationException the status code is already defined.

Just to be clear the exception mapping algorithm will choose the most
specific mapper according to the throwable class. Thus if you have:

   public class XMapper implements ExceptionMapper<Throwable> { ... }

   public class AMapper implements ExceptionMapper<A> { ... }

   public class BMapper implements ExceptionMapper<B> { ... }

   public class A extends Exception { ... }

   public class B extends A { ... }

   public class C extends A { ... }

then the following mappings will occur:

   - throw new Exception() -> XMapper

   - throw new A() -> AMapper();

   - throw new B() -> BMapper();

   - throw new C() -> AMapper();

Paul.

>
>>
>> Chris
>>
>> On Tue, Feb 2, 2010 at 11:08 AM, Robert Koberg <rob_at_koberg.com>
>> wrote:
>>>
>>> On Feb 2, 2010, at 10:23 AM, Paul Sandoz wrote:
>>>>
>>>> For any complete solution you will need to check the status code
>>>> and if any entity exists for e as your application may, in the
>>>> future say, throw a WebApplicationException or an extension of.
>>>
>>> How would you get the status code?
>>>
>>> -Rob
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>