From fe68d7df84d44b4e2e55017eaf8f3087e0f41198 Mon Sep 17 00:00:00 2001 From: Kim Daeun <iop2799@ajou.ac.kr> Date: Wed, 9 Apr 2025 18:11:25 +0900 Subject: [PATCH] Add delete Favorite_Exception --- .../procoding/myweb/service/MusicService.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/ajou/procoding/myweb/service/MusicService.java b/src/main/java/com/ajou/procoding/myweb/service/MusicService.java index 4f333d9..6b9b736 100644 --- a/src/main/java/com/ajou/procoding/myweb/service/MusicService.java +++ b/src/main/java/com/ajou/procoding/myweb/service/MusicService.java @@ -55,12 +55,18 @@ public class MusicService { // 존재하는지 확인 (없으면 예외 혹은 0 return 등) public int deleteFavorite(String id) { - if (albumsRepo.existsById(id)) { - albumsRepo.deleteById(id); - return 1; - } else { - return 0; - } + try { + if (albumsRepo.existsById(id)) { + albumsRepo.deleteById(id); + return 1; + } else { + return 0; + } + } catch (Exception e) { + System.out.println(e.toString()); + return 0; + } + } } \ No newline at end of file -- GitLab