users@jersey.java.net

Jersey client and exceptions

From: Denis AH-KANG <deniak.nospam_at_gmail.com>
Date: Thu, 12 Feb 2009 00:46:44 +0100

Hi all,

I have some questions about the jersey client and its exceptions.
Why does the client only throw runtime exceptions (ClientHandlerException
and
UniformInterfaceException)?

Actually, I need to use the client and manage the most common HTTP responses
(400, 404, 500...).
For the moment, I catch the client exception and get the status code from
it. It means I need
to create a switch case to handle each case. For instance:

catch(ClientHandlerException e) {
    switch(e.getResponse().getResponseStatus()):
        case 400:
            //some code
        case 404:
            //some code
        ....
}

Do you know if there's a better way to use the jersey client?

Thanks for your help.

Regards

--
Denis Ah-Kang