diff --git a/src/main/kotlin/roomescape/common/exception/CommonErrorCode.kt b/src/main/kotlin/roomescape/common/exception/CommonErrorCode.kt new file mode 100644 index 00000000..b69fc022 --- /dev/null +++ b/src/main/kotlin/roomescape/common/exception/CommonErrorCode.kt @@ -0,0 +1,20 @@ +package roomescape.common.exception + +import org.springframework.http.HttpStatus + +enum class CommonErrorCode( + override val httpStatus: HttpStatus, + override val errorCode: String, + override val message: String, +) : ErrorCode { + INVALID_INPUT_VALUE( + httpStatus = HttpStatus.BAD_REQUEST, + errorCode = "C001", + message = "요청 값이 잘못되었어요." + ), + UNEXPECTED_SERVER_ERROR( + httpStatus = HttpStatus.INTERNAL_SERVER_ERROR, + errorCode = "C999", + message = "서버에 예상치 못한 오류가 발생했어요. 관리자에게 문의해주세요.", + ), +} diff --git a/src/main/kotlin/roomescape/common/exception/ErrorCode.kt b/src/main/kotlin/roomescape/common/exception/ErrorCode.kt new file mode 100644 index 00000000..1f08d3b5 --- /dev/null +++ b/src/main/kotlin/roomescape/common/exception/ErrorCode.kt @@ -0,0 +1,9 @@ +package roomescape.common.exception + +import org.springframework.http.HttpStatus + +interface ErrorCode { + val httpStatus: HttpStatus + val errorCode: String + val message: String +} diff --git a/src/main/kotlin/roomescape/common/exception/RoomException.kt b/src/main/kotlin/roomescape/common/exception/RoomException.kt new file mode 100644 index 00000000..c75a1519 --- /dev/null +++ b/src/main/kotlin/roomescape/common/exception/RoomException.kt @@ -0,0 +1,6 @@ +package roomescape.common.exception + +open class RoomException( + open val errorCode: ErrorCode, + override val message: String? = errorCode.message +) : RuntimeException(message)