generated from pricelees/issue-pr-template
feat: 새로 사용할 커스텀 예외 객체 및 예외 코드 정의
This commit is contained in:
parent
830d3712e8
commit
7c30100f5a
@ -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 = "서버에 예상치 못한 오류가 발생했어요. 관리자에게 문의해주세요.",
|
||||
),
|
||||
}
|
||||
9
src/main/kotlin/roomescape/common/exception/ErrorCode.kt
Normal file
9
src/main/kotlin/roomescape/common/exception/ErrorCode.kt
Normal file
@ -0,0 +1,9 @@
|
||||
package roomescape.common.exception
|
||||
|
||||
import org.springframework.http.HttpStatus
|
||||
|
||||
interface ErrorCode {
|
||||
val httpStatus: HttpStatus
|
||||
val errorCode: String
|
||||
val message: String
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
package roomescape.common.exception
|
||||
|
||||
open class RoomException(
|
||||
open val errorCode: ErrorCode,
|
||||
override val message: String? = errorCode.message
|
||||
) : RuntimeException(message)
|
||||
Loading…
x
Reference in New Issue
Block a user