generated from pricelees/issue-pr-template
[#20] 도메인별 예외 분리 #21
@ -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