users@jersey.java.net

Re: Returning response in JSON format in case of Exceptions

From: j2eeuser32 <nagmidde_at_gmail.com>
Date: Mon, 10 May 2010 07:19:34 -0700 (PDT)

Paul,

Great, thank you. That helps a little bit.

My client is not Java based, that makes it difficult to catch the
UniformInterfaceException.

My intention is this:
Client should never see any exceptions and should not deal with getting the
entityText from the ClientResponse.
It should receive all types of responses (successful or errors/exceptions)
only in the String type (JSON formatted).

The client can have a logic to look for { "error" : { "messageKey" : 123,
"errorMessage" : "Invalid parameter ..." } } to see if it is an error
message. Otherwise, it is successful message.

I guess I have the following option:

1. To return a response status of less than 400 so that it wont throw an
UniformInterfaceException

My only concern is whether I am handling all types of exceptions to make
sure the response is always a String.

Thanks

-- 
View this message in context: http://jersey.576304.n2.nabble.com/Returning-response-in-JSON-format-in-case-of-Exceptions-tp4985840p5030805.html
Sent from the Jersey mailing list archive at Nabble.com.