users@jersey.java.net

Client API: How do you handle faults?

From: Jorge L Williams <Jorge.Williams_at_inl.gov>
Date: Thu, 16 Oct 2008 14:59:14 -0600

Hey guys,

I'm thinking of using the Client API, but before I do I have a question
regarding how expected faults are handled.

From looking at the JavaDoc it seems that I can do something like this...

Client c = Client.create();

WebResource r = c.resource("http://host/people/chuckNorris");
JaxbPerson chuck = r.get(JaxbPerson.class);

...

If chuck exists everything is okay, but if chuck doesn't exist the Jax-RS
service returns a status code of 404 and an object of type JaxbFault.
What's the best way of handling this in the Client API?


Thanks,

jOrGe W.