You should set the HTTP status code to an appropriate value, in the 400 or 500 range, via getResponse().setStatus(). See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10. For your example, 401 Bad Request would be appropriate.
You can also return a representation that may return additional context information about the error, but there are no REST standards for this; the status code itself should be enough for the client to intelligently interpret. In Resource.put(), you'd return a Representation object after you set the response status code. .. Adam On Sun, Mar 23, 2008 at 7:05 PM, Ian Clarke <[EMAIL PROTECTED]> wrote: > What is the appropriate way to report an error back to the caller of a > HTTP REST call from a Resource class? > > For example, what if I'm using JSON and there is some kind of JSON > parsing error? Obviously, it would be nice to return a useful error > message to the caller of the API. > > I'd really appreciate some example code, say, from within a > Resource.put() method. > > Ian. > > -- > Email: [EMAIL PROTECTED] > Cell: +1 512 422 3588 > Skype: sanity >