@@ -282,7 +282,7 @@ private enum UpdateType {
282282 @ Transactional
283283 public StudyPlanResponse updateStudyPlan (Long userId , Long planId , StudyPlanRequest request , StudyPlanException .ApplyScope applyScope ) {
284284 StudyPlan originalPlan = studyPlanRepository .findById (planId )
285- .orElseThrow (() -> new CustomException (ErrorCode .NOT_FOUND ));
285+ .orElseThrow (() -> new CustomException (ErrorCode .PLAN_NOT_FOUND ));
286286
287287 validateUserAccess (originalPlan , userId );
288288
@@ -319,7 +319,7 @@ private UpdateType determineUpdateType(StudyPlan originalPlan, StudyPlanRequest
319319 return UpdateType .ORIGINAL_PLAN_UPDATE ;
320320 }
321321
322- // 1-2. 반복 계획에서 다른 날짜인 경우 -> 기존 예외 확인
322+ // 1-2. 반복 계획에서 다른 날짜인 경우 -> 기존 예외 존재 유무 확인
323323 Optional <StudyPlanException > existingException = studyPlanExceptionRepository
324324 .findByPlanIdAndDate (originalPlan .getId (), requestDate );
325325
@@ -353,7 +353,7 @@ private StudyPlanResponse createRepeatException(StudyPlan originalPlan, StudyPla
353353
354354 // 해당 날짜에 실제로 반복 계획이 있는지 확인
355355 if (!shouldRepeatOnDate (originalPlan , exceptionDate )) {
356- throw new CustomException (ErrorCode .BAD_REQUEST );
356+ throw new CustomException (ErrorCode .PLAN_ORIGINAL_REPEAT_NOT_FOUND );
357357 }
358358
359359 StudyPlanException exception = new StudyPlanException ();
@@ -380,7 +380,7 @@ private StudyPlanResponse createRepeatException(StudyPlan originalPlan, StudyPla
380380 LocalDate untilDate = LocalDate .parse (request .getRepeatRule ().getUntilDate ());
381381 embeddable .setUntilDate (untilDate );
382382 } catch (Exception e ) {
383- throw new CustomException (ErrorCode .BAD_REQUEST );
383+ throw new CustomException (ErrorCode .PLAN_INVALID_DATE_FORMAT );
384384 }
385385 }
386386
@@ -398,7 +398,7 @@ private StudyPlanResponse updateExistingException(StudyPlan originalPlan, StudyP
398398
399399 StudyPlanException existingException = studyPlanExceptionRepository
400400 .findByPlanIdAndDate (originalPlan .getId (), exceptionDate )
401- .orElseThrow (() -> new CustomException ( ErrorCode . NOT_FOUND ) );
401+ .orElse ( null );
402402
403403 // 기존 예외 정보 업데이트
404404 if (request .getSubject () != null ) existingException .setModifiedSubject (request .getSubject ());
@@ -421,7 +421,7 @@ private StudyPlanResponse updateExistingException(StudyPlan originalPlan, StudyP
421421 LocalDate untilDate = LocalDate .parse (request .getRepeatRule ().getUntilDate ());
422422 embeddable .setUntilDate (untilDate );
423423 } catch (Exception e ) {
424- throw new CustomException (ErrorCode .BAD_REQUEST );
424+ throw new CustomException (ErrorCode .PLAN_INVALID_DATE_FORMAT );
425425 }
426426 }
427427
@@ -444,7 +444,7 @@ private void updateRepeatRule(RepeatRule repeatRule, StudyPlanRequest.RepeatRule
444444 LocalDate untilDate = LocalDate .parse (request .getUntilDate ());
445445 repeatRule .setUntilDate (untilDate );
446446 } catch (Exception e ) {
447- throw new CustomException (ErrorCode .BAD_REQUEST );
447+ throw new CustomException (ErrorCode .PLAN_INVALID_DATE_FORMAT );
448448 }
449449 }
450450 }
@@ -453,7 +453,7 @@ private void updateRepeatRule(RepeatRule repeatRule, StudyPlanRequest.RepeatRule
453453 @ Transactional
454454 public void deleteStudyPlan (Long userId , Long planId , LocalDate selectedDate , StudyPlanDeleteRequest request ) {
455455 StudyPlan studyPlan = studyPlanRepository .findById (planId )
456- .orElseThrow (() -> new CustomException (ErrorCode .NOT_FOUND ));
456+ .orElseThrow (() -> new CustomException (ErrorCode .PLAN_NOT_FOUND ));
457457
458458 validateUserAccess (studyPlan , userId );
459459
@@ -503,6 +503,4 @@ private void validateUserAccess(StudyPlan studyPlan, Long userId) {
503503 }
504504
505505
506-
507-
508506}
0 commit comments