[#20] 도메인별 예외 분리 #21

Merged
pricelees merged 37 commits from refactor/#20 into main 2025-07-24 02:48:53 +00:00
Showing only changes of commit 75afa45224 - Show all commits

View File

@ -9,11 +9,21 @@ import org.springframework.web.bind.MethodArgumentNotValidException
import org.springframework.web.bind.annotation.ExceptionHandler import org.springframework.web.bind.annotation.ExceptionHandler
import org.springframework.web.bind.annotation.RestControllerAdvice import org.springframework.web.bind.annotation.RestControllerAdvice
import roomescape.common.dto.response.CommonErrorResponse import roomescape.common.dto.response.CommonErrorResponse
import roomescape.common.dto.response.CommonErrorResponseV2
@RestControllerAdvice @RestControllerAdvice
class ExceptionControllerAdvice( class ExceptionControllerAdvice(
private val logger: KLogger = KotlinLogging.logger {} private val logger: KLogger = KotlinLogging.logger {}
) { ) {
@ExceptionHandler(value = [RoomescapeExceptionV2::class])
fun handleRoomException(e: RoomescapeExceptionV2): ResponseEntity<CommonErrorResponseV2> {
logger.error(e) { "message: ${e.message}" }
val errorCode: ErrorCode = e.errorCode
val httpStatus: Int = errorCode.httpStatus.value()
return ResponseEntity.status(httpStatus)
.body(CommonErrorResponseV2(errorCode, e.message))
}
@ExceptionHandler(value = [RoomescapeException::class]) @ExceptionHandler(value = [RoomescapeException::class])
fun handleRoomEscapeException(e: RoomescapeException): ResponseEntity<CommonErrorResponse> { fun handleRoomEscapeException(e: RoomescapeException): ResponseEntity<CommonErrorResponse> {