All you need to do is throw javax.ws.rs.WebApplicationException. You don't have to change the method signature, you can still return the normal domain class when the method is successful.
@Path("{id}") public SessionResource getSession(@PathParam("id") String id) { try { // ........... } catch (IllegalArgumentException e) { throw new WebApplicationException(e, Status.NOT_FOUND); } }That's it!
No comments:
Post a Comment