Instantly share code, notes, and snippets.

Embed
What would you like to do?
3rd version of ReservationController with Exception Handler
@RestController
@RequestMapping("/reservation")
public class ReservationController {
private ReservationService reservationService;
public ReservationController(ReservationService reservationService) {
this.reservationService = reservationService;
}
@RequestMapping(method = RequestMethod.GET, value = "/{name}")
private Reservation getReservation(@PathVariable String name) {
System.out.println("Entering and leaving ReservationController : getReservation after fetching service");
return reservationService.getReservationDetails(name);
}
@ExceptionHandler()
@ResponseStatus(HttpStatus.NOT_FOUND)
public void userNotFoundHandler(ReservationNotFoundException rnfe) {
System.out.println("Entering and leaving ReservationController : userNotFoundHandler");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment