Skip to content

Instantly share code, notes, and snippets.

@CheolhoJeon
Created April 28, 2020 02:00
Show Gist options
  • Save CheolhoJeon/318e585758d750ce2242ff2bf1af4170 to your computer and use it in GitHub Desktop.
Save CheolhoJeon/318e585758d750ce2242ff2bf1af4170 to your computer and use it in GitHub Desktop.
@GetMapping("/api/members/{id}")
public ResponseEntity<Object> member(@PathVariable Long id, HttpServletResponse response) {
Member member = memberDao.selectById(id);
if (member == null) {
throw new MemberNotFoundException();
}
return ResponseEntity.status(HttpStatus.OK).body(member);
}
@ExceptionHandler(MemberNotFoundException.class)
public ResponseEntity<Object> handleNoData() {
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ErrorResponse("no member"));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment