Created
June 12, 2012 10:00
-
-
Save sivaprasadreddy/2916676 to your computer and use it in GitHub Desktop.
RESTEasy Demo Throwing Custom Exceptions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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