David,
Thanks for your response. I should have been more clear. I was wondering the
proper way from a service standpoint to return an error.
For example when inheriting from Resource in the server, - if the following code
generates an exception - is it better to return an error via the response or
throw an exception?
<code>
public void acceptRepresentation(Representation entity)
throws ResourceException {
try {
// Set the response's status and entity
} catch (Exception e) {
// OPTION 1
// which is the best way to return an error?????
// set it in the response as follows
response.setStatus(Status.CLIENT_ERROR_NOT_FOUND);
response.setEntity("Error", MediaType.TEXT_PLAIN)
// OR
// OPTION 2
throw new ResourceException(Status.CLIENT_ERROR_NOT_FOUND, "Error", e);
}
}
</code>