Created
May 4, 2017 16:52
-
-
Save abdulbasitkay/d22a8cd94f63ec27689d4fd2ecb2877f to your computer and use it in GitHub Desktop.
Question Resource with error handling
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("questions/") | |
public class QuestionResource { | |
@GET | |
@Path("{id}") | |
@Produces("application/json") | |
Response getQuestion(@PathParam("id") String questionId) { | |
QuestionDto question = questionService.getQuestionById(questionId); | |
if (question == null) | |
throw new ApiException(404, "Question not found", "Make sure the Id is valid and a question has been created"); | |
return Response.status(OK).entity(question).build(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment