Last active
March 11, 2018 02:44
-
-
Save dhaval201279/275686348f9f1ee59d58ef51f39047c2 to your computer and use it in GitHub Desktop.
3rd version of ReservationController with Exception Handler
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
@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