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.