Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sivaprasadreddy/2916676 to your computer and use it in GitHub Desktop.
Save sivaprasadreddy/2916676 to your computer and use it in GitHub Desktop.
RESTEasy Demo Throwing Custom Exceptions
@Path("/{id}")
@GET
public Response getUserXMLById(@PathParam("id") Integer id)
{
if(id==null || id < 1 ){
throw new ApplicationException("User Id["+id+"] should not be less than 1.");
}
User user = userService.getById(id);
if(user==null ){
throw new ResourceNotFoundException("No User found with Id :["+id+"]");
}
return Response.ok(user).build();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment