dev@jersey.java.net

Re: [Jersey] HTTP error codes throws by Jersey

From: exxos <hatufr_at_gmail.com>
Date: Fri, 10 Sep 2010 16:17:56 +0200

Thank you for this clarification.

Sincerly,
exxos.

On Fri, Sep 10, 2010 at 4:07 PM, Paul Sandoz <Paul.Sandoz_at_oracle.com> wrote:

>
> On Sep 10, 2010, at 3:28 PM, exxos wrote:
>
> Hi,
>>
>> How can we know the HTTP error codes that Jersey can throw?
>> If you look at the WebApplicationException, one of its constructors, waits
>> for a Response.Status. If all Jersey's runtime exception inherite from
>> WebApplicationException, only the HTTP error codes defined in
>> Response.Status will be thrown.
>>
>
> There are other constructors on WebApplicationException. If you want to
> consistently handle WebApplicationException thrown from Jersey or the
> application you need to look at Response of
> WebApplicationException.getResponse.
>
> Unfortunately Response does not return StatusType, which is a bug in the
> API (the Jersey implementation of Response retains it).
>
>
>
> But the javadoc of the JSR-311 informs that Response.Status can be extended
>> by the implementation (here is Jersey) using Response.StatusType.
>>
>> ErrorHandler extends ExceptionMapper<RuntimeException>
>>
>> Finally, what are the runtime exceptions possible with Jersey? Which kind
>> of runtime exceptions can be thrown?
>>
>>
> Jersey will internally throw WebApplicationException or extensions of for
> exceptions that are mapped to responses (such as 400, 404, 405, 406, 415 and
> 500). It will not use any exception mappers for such purposes.
>
> Any unmapped runtime exception thrown by the application or Jersey (the
> latter of which potentially signals a bug in Jersey) will be passed through
> to the HTTP container.
>
> Any unmapped checked exception thrown by the application will be wrapped in
> runtime exception MappableContainerException and re-thrown.
>
> When deployed in a servlet container a runtime exception is passed through
> to the servlet layer, except for a MappableContainerException the cause of
> which is wrapped in a ServletException and rethrown.
>
> Paul.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: dev-help_at_jersey.dev.java.net
>
>