diff --git a/backend/src/main/java/com/example/backend/service/MovieService.java b/backend/src/main/java/com/example/backend/service/MovieService.java index cb88273..9bfdafe 100644 --- a/backend/src/main/java/com/example/backend/service/MovieService.java +++ b/backend/src/main/java/com/example/backend/service/MovieService.java @@ -23,10 +23,8 @@ public List getAllMovies() { } public Movie getMovieById(Long movieId) { - if (movieRepository.existsById(movieId)) { - return movieRepository.findById(movieId).get(); - } - throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Movie with id " + movieId + " does not exist"); + return movieRepository.findById(movieId) + .orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, "Movie with id " + movieId + " not found")); } public void deleteMovie(Long movieId) {