generated from pricelees/issue-pr-template
feat: 새로 추가된 커스텀 예외 핸들링 추가
This commit is contained in:
parent
c6a5927b72
commit
75afa45224
@ -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> {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user