Hi
On 18/08/16 14:32, J. Fiala wrote:
Hi,
I just came across the Exception handling behaviour of CXF 3 and was
wondering if this is intended:
1.) Passing simply a string as message results in message is not
included in the response.
throw new InternalServerErrorException("message");
==> will return only Status: 500
Status : 500
Headers :
connection : close
Content-Length : 0
Date : Thu, 18 Aug 2016 13:23:42 GMT
Server : Apache-Coyote/1.1
2.) Passing a Reponse will result in the desired behaviour:
throw new
InternalServerErrorException(Response.status(Status.INTERNAL_SERVER_ERROR).entity("message").build());
==> will return
Status : 500
Headers :
connection : close
Content-Length : 81
content-type : application/json
Date : Thu, 18 Aug 2016 13:24:33 GMT
Server : Apache-Coyote/1.1
Error message :
message
Is there a specific reason why the simpler form will not return the
message?
in case 1) it is the error message passed to RuntimeException 2) we have
a Response entity prepared and it is being reported
3.) However, if any RuntimeException occurs during the call, CXF3 will
by default return the complete stack trace to the client with Status 500.
Is there any way to prevent this (by using an Exception Handler or so...)?
Yes
Sergey
Best regards,
Johannes
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/