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

[jsr339-experts] Re: Exception getMessage() on the client side

From: Sergey Beryozkin <sberyozkin_at_talend.com>
Date: Tue, 4 Sep 2012 14:31:30 +0100

On 04/09/12 14:24, Bill Burke wrote:
>
>
> On 9/4/2012 8:30 AM, Sergey Beryozkin wrote:
>> Hi
>>
>> Suppose we have a server returning 500 and also choosing to add some
>> text in the response body.
>>
>> We can write:
>>
>> catch (ServerErrorException ex) {
>>
>> String errorMessage = ex.getResponse().readEntity(String.class);
>>
>> }
>>
>> Would it make sense to request that
>>
>> ex.getMessage() is equivalent to
>> ex.getResponse().readEntity(String.class);
>>
>> ?
>>
>> Cheers, Sergey
>
> I would say no.
>
Did you forget to say 'why' :-) ?

Returning 'null' for ex.getMessage() is not a big issue, but in the
context of the client processing the server exception response

ex.getMessage() == null
ex.getResponse().readEntity(String.class) != null

does not seem consistent. To me,
"ex.getResponse().readEntity(String.class)" is an exception message too.

Just a thought really,


Cheers, Sergey