From 6c22a08a08cde3fa521a2657598153e5ddf7d180 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Thu, 26 Sep 2024 14:18:53 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=95=84=ED=8B=B0=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=9E=A5=EB=A5=B4=20=EC=A0=80=EC=9E=A5=20=EC=98=88=EC=99=B8?= =?UTF-8?q?=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/org/example/usecase/ArtistUseCase.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/domain/show-domain/src/main/java/org/example/usecase/ArtistUseCase.java b/app/domain/show-domain/src/main/java/org/example/usecase/ArtistUseCase.java index 18e36d33..fe229d68 100644 --- a/app/domain/show-domain/src/main/java/org/example/usecase/ArtistUseCase.java +++ b/app/domain/show-domain/src/main/java/org/example/usecase/ArtistUseCase.java @@ -7,6 +7,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.example.dto.artist.param.ArtistNamesWithShowIdDomainParam; import org.example.dto.artist.request.ArtistGenreDomainRequest; import org.example.dto.artist.request.ArtistPaginationDomainRequest; @@ -33,6 +34,7 @@ import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; +@Slf4j @Component @RequiredArgsConstructor public class ArtistUseCase { @@ -51,10 +53,14 @@ public void save(ArtistWithGenreCreateDomainRequest request) { Artist newArtist = artistGenre.toArtist(); artistRepository.save(newArtist); - Genre genre = genreRepository.findByName(artistGenre.genreName()) - .orElseThrow(NoSuchElementException::new); + try { + Genre genre = genreRepository.findByName(artistGenre.genreName()) + .orElseThrow(NoSuchElementException::new); - artistGenreRepository.save(newArtist.toArtistGenre(genre.getId())); + artistGenreRepository.save(newArtist.toArtistGenre(genre.getId())); + } catch (NoSuchElementException e) { + log.warn("해당하는 장르가 존재하지 않습니다."); + } } }