From 899e7563f05eb00f931b2191b6fa177e5a248044 Mon Sep 17 00:00:00 2001 From: 1026hz <1026hzz@gmail.com> Date: Thu, 20 Feb 2025 18:51:59 +0900 Subject: [PATCH] =?UTF-8?q?[FIX]=20=EC=8B=9D=EB=8B=A8=EB=8C=80=EB=A1=9C=20?= =?UTF-8?q?=EB=A8=B9=EC=97=88=EC=9D=84=20=EC=8B=9C=EC=9D=98=20=EA=B8=B0?= =?UTF-8?q?=EB=A1=9D=20=EC=9D=91=EB=8B=B5=20=EA=B5=AC=EC=B2=B4=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/umc7th/bulk/global/error/GeneralErrorCode.java | 4 ++++ .../java/umc7th/bulk/record/service/RecordServiceImpl.java | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/umc7th/bulk/global/error/GeneralErrorCode.java b/src/main/java/umc7th/bulk/global/error/GeneralErrorCode.java index fa734da..56f1978 100644 --- a/src/main/java/umc7th/bulk/global/error/GeneralErrorCode.java +++ b/src/main/java/umc7th/bulk/global/error/GeneralErrorCode.java @@ -27,6 +27,10 @@ public enum GeneralErrorCode implements BaseErrorCode { //500 INTERNAL_SERVER_ERROR_500(HttpStatus.INTERNAL_SERVER_ERROR, "COMMON500", "서버 내부 오류가 발생했습니다."), + + //기록 + RECORD_ALREADY_EXISTS(HttpStatus.BAD_REQUEST,"RECORD400", "이미 해당 날짜와 끼니에 대한 기록이 존재합니다."), + MEAL_PLAN_NOT_FOUND(HttpStatus.NOT_FOUND, "RECORD404", "해당 끼니의 식단을 찾을 수 없습니다."); ; diff --git a/src/main/java/umc7th/bulk/record/service/RecordServiceImpl.java b/src/main/java/umc7th/bulk/record/service/RecordServiceImpl.java index efaa6fd..041c080 100644 --- a/src/main/java/umc7th/bulk/record/service/RecordServiceImpl.java +++ b/src/main/java/umc7th/bulk/record/service/RecordServiceImpl.java @@ -64,7 +64,7 @@ public RecordResponseDto createRecord(RecordRequestDto.Create requestDto) { .orElse(null); if (existingRecord != null) { - throw new IllegalArgumentException("이미 해당 날짜와 끼니에 대한 기록이 존재합니다."); + throw new CustomException(GeneralErrorCode.RECORD_ALREADY_EXISTS); } // 사용자의 해당 날짜 기록 확인 @@ -76,7 +76,7 @@ public RecordResponseDto createRecord(RecordRequestDto.Create requestDto) { requestDto.getDate(), requestDto.getMealType()); if (mealMappings.isEmpty()) { - throw new IllegalArgumentException("해당 끼니의 식단을 찾을 수 없습니다."); + throw new CustomException(GeneralErrorCode.MEAL_PLAN_NOT_FOUND); } // 새로운 Record 생성