diff --git a/src/main/kotlin/roomescape/common/exception/ExceptionControllerAdvice.kt b/src/main/kotlin/roomescape/common/exception/ExceptionControllerAdvice.kt index 2a877347..5037d01d 100644 --- a/src/main/kotlin/roomescape/common/exception/ExceptionControllerAdvice.kt +++ b/src/main/kotlin/roomescape/common/exception/ExceptionControllerAdvice.kt @@ -11,48 +11,46 @@ import roomescape.common.dto.response.CommonErrorResponse @RestControllerAdvice class ExceptionControllerAdvice( - private val logger: KLogger = KotlinLogging.logger {} + private val log: KLogger = KotlinLogging.logger {} ) { @ExceptionHandler(value = [RoomescapeException::class]) fun handleRoomException(e: RoomescapeException): ResponseEntity { - logger.error(e) { "message: ${e.message}" } - val errorCode: ErrorCode = e.errorCode return ResponseEntity - .status(errorCode.httpStatus) - .body(CommonErrorResponse(errorCode, e.message)) + .status(errorCode.httpStatus) + .body(CommonErrorResponse(errorCode, e.message)) } @ExceptionHandler(value = [HttpMessageNotReadableException::class]) fun handleHttpMessageNotReadableException(e: HttpMessageNotReadableException): ResponseEntity { - logger.error(e) { "message: ${e.message}" } + log.debug { "message: ${e.message}" } val errorCode: ErrorCode = CommonErrorCode.INVALID_INPUT_VALUE return ResponseEntity - .status(errorCode.httpStatus) - .body(CommonErrorResponse(errorCode)) + .status(errorCode.httpStatus) + .body(CommonErrorResponse(errorCode)) } @ExceptionHandler(value = [MethodArgumentNotValidException::class]) fun handleMethodArgumentNotValidException(e: MethodArgumentNotValidException): ResponseEntity { val message: String = e.bindingResult.allErrors - .mapNotNull { it.defaultMessage } - .joinToString(", ") - logger.error(e) { "message: $message" } + .mapNotNull { it.defaultMessage } + .joinToString(", ") + log.debug { "message: $message" } val errorCode: ErrorCode = CommonErrorCode.INVALID_INPUT_VALUE return ResponseEntity - .status(errorCode.httpStatus) - .body(CommonErrorResponse(errorCode)) + .status(errorCode.httpStatus) + .body(CommonErrorResponse(errorCode)) } @ExceptionHandler(value = [Exception::class]) fun handleException(e: Exception): ResponseEntity { - logger.error(e) { "message: ${e.message}" } + log.error(e) { "message: ${e.message}" } val errorCode: ErrorCode = CommonErrorCode.UNEXPECTED_SERVER_ERROR return ResponseEntity - .status(errorCode.httpStatus) - .body(CommonErrorResponse(errorCode)) + .status(errorCode.httpStatus) + .body(CommonErrorResponse(errorCode)) } }