Use Exceptions to Send Error Responses in Jersey

Jersey provides several different ways to send back particular HTTP responses.  While your resource methods can all return Response objects, sometimes it’s more natural to return a domain object if everything goes OK and throw exceptions when errors occur. The WebApplicationException class serves this purpose.  You throw an instance of it in your resource method,…