Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

도메인 모듈 내에서 사용할 Exception을 정의합니다. #24

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.whatever.raisedragon.common.exception

class BaseException(
val exceptionCode: ExceptionCode,
override val message: String,
override val cause: Throwable?,
) : RuntimeException(
message,
cause
) {

companion object {
fun of(
exceptionCode: ExceptionCode,
executionMessage: String,
cause: Throwable? = null
): BaseException {
return BaseException(
exceptionCode = exceptionCode,
message = executionMessage,
cause = cause
)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.whatever.raisedragon.common.exception

import org.springframework.http.HttpStatus

enum class ExceptionCode(
val httpStatus: HttpStatus,
val code: String,
val message: String,
) {

E400_BAD_REQUEST(HttpStatus.BAD_REQUEST, "000", "필수 파라미터 값이 없거나 잘못된 값으로 요청을 보낸 경우 발생"),

// ------------------------------ 401 ------------------------------
E401_UNAUTHORIZED(HttpStatus.UNAUTHORIZED, "000", "유효하지 않은 인증 토큰을 사용한 경우 발생"),

// ------------------------------ 403 ------------------------------
E403_FORBIDDEN(HttpStatus.FORBIDDEN, "000", "사용 권한이 없는 경우 발생"),

// ------------------------------ 404 ------------------------------
E404_NOT_FOUND(HttpStatus.NOT_FOUND, "000", "요청한 리소스가 존재하지 않는 경우 발생"),

// ------------------------------ 405 ------------------------------
E405_METHOD_NOT_ALLOWED(HttpStatus.METHOD_NOT_ALLOWED, "000", "HTTP Method가 잘못된 경우"),

// ------------------------------ 409 ------------------------------
E409_CONFLICT(HttpStatus.CONFLICT, "000", "요청한 리소스가 중복된 경우 발생"),

// ------------------------------ 500 ------------------------------
E500_INTERNAL_SERVER_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "000", "서버 내부에 문제 발생"),

// ------------------------------ 501 ------------------------------
E501_NOT_IMPLEMENTED(HttpStatus.NOT_IMPLEMENTED, "000", "지원하지 않는 타입의 요청"),
}