[ 
https://issues.apache.org/jira/browse/CXF-3150?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Sergey Beryozkin resolved CXF-3150.
-----------------------------------

       Resolution: Fixed
    Fix Version/s: 2.4
                   2.3.2
         Assignee: Sergey Beryozkin

I've introduced two exception classes. 

One is ServerWebApplicationException which extends WebApplicationException and 
make it easy to get to the status, headers, and the response message if any. 
ServerWebApplicationException is thrown only if the request has actually been 
made and the server returned a status >=400.

The other one is ClientWebApplicationException which is thrown in cases when no 
request has actually been made for whatever reasons. It extends the 
RuntimeException. Thus the client code which expects WebApplicationException be 
thrown even when no request has been made will become broken given this change. 
However - as you rightly noticed, WebApplicationException currently thrown on 
2.3.0/2.3.1 are of little use in case of the client errors - thus I think this 
change is actually fixing an issue and thus is needed.

Note - you do not  have to use ServerWebApplicationException if you need to 
check the status, etc. You can get a JAX-RS Response from 
WebApplicationException too, ServerWebApplicationException just makes it easier 
to deal with the Response.

Besides, you can always get to the underlying response even with catching a 
runtime exception, this code will work for proxies :

Client client = WebClient.client(proxy);
// this one works for WebClient
client.getResponse()

Finally - you can register a custom WebApplicationExceptionMapper on the server 
side and include a stack trace if you wish - CXF JAX-RS just does not sent the 
actual code details by default.

http://svn.apache.org/viewvc?rev=1042724&view=rev

Any comments - let me know please

thanks, Sergey

> WebApplicationException and Response do not implement a useful 
> toString()/getMessage() method
> ---------------------------------------------------------------------------------------------
>
>                 Key: CXF-3150
>                 URL: https://issues.apache.org/jira/browse/CXF-3150
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.3.0
>            Reporter: Dobes Vandermeer
>            Assignee: Sergey Beryozkin
>             Fix For: 2.3.2, 2.4
>
>
> When using the client API, the WebApplicationExceptions are very opaque, it 
> just says "WebApplicationException".
> It would be nice if the printStackTrace() on these would, without additional 
> work, print out at least the status code and possibly the response body if it 
> meets some criteria (any way I can send back a useful error message from the 
> server would be great).  The WebApplicationExceptions thrown by the client 
> itself also seem to be lacking much useful information.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to