Skip to content

Commit

Permalink
Code readability improved
Browse files Browse the repository at this point in the history
  • Loading branch information
Krisssssssssssssssssssssss committed Oct 16, 2024
1 parent 09bc8c3 commit e0c0a47
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ public List<Movie> 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) {
Expand Down

0 comments on commit e0c0a47

Please sign in to comment.