diff --git a/src/main/java/org/withtime/be/withtimebe/domain/weather/dto/request/WeatherReqDTO.java b/src/main/java/org/withtime/be/withtimebe/domain/weather/dto/request/WeatherReqDTO.java index 3322f30..413f8d0 100644 --- a/src/main/java/org/withtime/be/withtimebe/domain/weather/dto/request/WeatherReqDTO.java +++ b/src/main/java/org/withtime/be/withtimebe/domain/weather/dto/request/WeatherReqDTO.java @@ -2,6 +2,8 @@ import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Positive; +import org.withtime.be.withtimebe.global.error.code.WeatherErrorCode; +import org.withtime.be.withtimebe.global.error.exception.WeatherException; import java.time.LocalDate; @@ -26,8 +28,7 @@ public static GetWeeklyRecommendation of(Long regionId, LocalDate startDate) { LocalDate maxDate = now.plusDays(7); if (startDate.isBefore(minDate) || startDate.isAfter(maxDate)) { - throw new IllegalArgumentException( - "조회 가능한 시작 날짜 범위를 벗어났습니다. (7일 전 ~ 7일 후)"); + throw new WeatherException(WeatherErrorCode.INVALID_DATE_RANGE); } } @@ -57,8 +58,7 @@ public static GetWeeklyPrecipitation of(Long regionId, LocalDate startDate) { LocalDate maxDate = now.plusDays(10); if (startDate.isBefore(minDate) || startDate.isAfter(maxDate)) { - throw new IllegalArgumentException( - "조회 가능한 시작 날짜 범위를 벗어났습니다. (7일 전 ~ 10일 후)"); + throw new WeatherException(WeatherErrorCode.INVALID_DATE_RANGE); } } diff --git a/src/main/java/org/withtime/be/withtimebe/domain/weather/service/command/WeatherTriggerServiceImpl.java b/src/main/java/org/withtime/be/withtimebe/domain/weather/service/command/WeatherTriggerServiceImpl.java index a381a0d..f80a61b 100644 --- a/src/main/java/org/withtime/be/withtimebe/domain/weather/service/command/WeatherTriggerServiceImpl.java +++ b/src/main/java/org/withtime/be/withtimebe/domain/weather/service/command/WeatherTriggerServiceImpl.java @@ -9,6 +9,8 @@ import org.withtime.be.withtimebe.domain.weather.data.utils.WeatherDataHelper; import org.withtime.be.withtimebe.domain.weather.dto.request.WeatherSyncReqDTO; import org.withtime.be.withtimebe.domain.weather.dto.response.WeatherSyncResDTO; +import org.withtime.be.withtimebe.global.error.code.WeatherErrorCode; +import org.withtime.be.withtimebe.global.error.exception.WeatherException; import java.time.LocalDate; import java.time.LocalDateTime; @@ -109,7 +111,7 @@ private Object executeJob(WeatherSyncReqDTO.ManualTrigger request) { .build(); } - default -> throw new IllegalArgumentException("지원하지 않는 작업 타입: " + request.jobType()); + default -> throw new WeatherException(WeatherErrorCode.UNSUPPORTED_TASK_TYPE); }; } } diff --git a/src/main/java/org/withtime/be/withtimebe/global/error/code/WeatherErrorCode.java b/src/main/java/org/withtime/be/withtimebe/global/error/code/WeatherErrorCode.java index 9e766b9..392cd28 100644 --- a/src/main/java/org/withtime/be/withtimebe/global/error/code/WeatherErrorCode.java +++ b/src/main/java/org/withtime/be/withtimebe/global/error/code/WeatherErrorCode.java @@ -21,10 +21,11 @@ public enum WeatherErrorCode implements BaseErrorCode { REGION_ALREADY_EXISTS(HttpStatus.BAD_REQUEST, "WEATHER400_0", "이미 존재하는 지역입니다."), WEATHER_TEMPLATE_ALREADY_EXISTS(HttpStatus.BAD_REQUEST, "WEATHER400_1", "이미 존재하는 날씨 템플릿입니다."), INVALID_COORDINATES(HttpStatus.BAD_REQUEST, "WEATHER400_2", "올바르지 않은 좌표입니다."), - INVALID_DATE_RANGE(HttpStatus.BAD_REQUEST, "WEATHER400_3", "올바르지 않은 날짜 범위입니다."), + INVALID_DATE_RANGE(HttpStatus.BAD_REQUEST, "WEATHER400_3", "올바르지 않은 날짜 범위입니다. 조회 가능한 시작 날짜 범위를 벗어났습니다. (7일 전 ~ 7일 후)"), INVALID_WEATHER_DATA(HttpStatus.BAD_REQUEST, "WEATHER400_4", "올바르지 않은 날씨 데이터입니다."), INVALID_REGION_CODE(HttpStatus.BAD_REQUEST, "WEATHER400_5", "올바르지 않은 지역코드입니다."), INVALID_ENUM_VALUE(HttpStatus.BAD_REQUEST, "WEATHER400_6", "올바르지 않은 열거형 값입니다."), + UNSUPPORTED_TASK_TYPE(HttpStatus.BAD_REQUEST, "WEATHER400_7", "지원하지 않는 작업 타입입니다."), // ==== 권한/인증 에러 (403) ==== ACCESS_DENIED(HttpStatus.FORBIDDEN, "WEATHER403_0", "접근 권한이 없습니다."),