jsr339-experts@jax-rs-spec.java.net

[jsr339-experts] Re: client exception processing not what we agreed...

From: Bill Burke <bburke_at_redhat.com>
Date: Fri, 08 Feb 2013 18:00:59 -0500

On 2/8/2013 2:41 PM, Bill Burke wrote:
> This is valid JAX-RS 2.0 exception handling correct?
>
> try {
> String result = webTarget.request().get(String.class);
> } catch (NotFoundException ex) {
> } catch (...) {}
>
> All the WebAplicationException derivatives are thrown from all methods
> that don't return Response, correct?
>
>
> I'm looking at the Javadoc of AsyncInvoker:
>
> * In case a processing of a properly received response fails, the
> wrapped processing exception
> * will be of {_at_link ResponseProcessingException} type and will
> contain the {_at_link Response}
> * instance whose processing has failed.
>
> It doesn't seem like this is the same for async invocations, which I
> think it wrong. Async invocations should also be similar to sync.
>
> Future<String> future = webTarget.request().async().get(String.class);
>
> try {
> String result = future.get();
> } catch (NotFoundException ex) {
> } catch (...) {...}
>
> It sounds like from the javadoc that everything is wrapped within a
> ResponseProcessingException.
>

Actually, because of the Future contract it probably has to be something
like this:

} catch (ExecutionException ex) {

    if (ex.getCause() instanceof NotFoundException) {...}
}


-- 
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com