From 979623a67061fd45514d7b4d7af3f48fc0a827f8 Mon Sep 17 00:00:00 2001 From: pricelees Date: Tue, 7 Oct 2025 22:17:01 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20GlobalExceptionHandler=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EC=BB=A4=EC=8A=A4=ED=85=80=20=EC=98=88=EC=99=B8?= =?UTF-8?q?=EB=8A=94=20INFO=20=EB=A1=9C=EA=B7=B8=EB=A1=9C=20=EA=B8=B0?= =?UTF-8?q?=EB=A1=9D=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/web/exception/GlobalExceptionhandler.kt | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/common/web/src/main/kotlin/com/sangdol/common/web/exception/GlobalExceptionhandler.kt b/common/web/src/main/kotlin/com/sangdol/common/web/exception/GlobalExceptionhandler.kt index cab24523..bba98c3e 100644 --- a/common/web/src/main/kotlin/com/sangdol/common/web/exception/GlobalExceptionhandler.kt +++ b/common/web/src/main/kotlin/com/sangdol/common/web/exception/GlobalExceptionhandler.kt @@ -30,7 +30,7 @@ class GlobalExceptionHandler( val httpStatus: HttpStatus = errorCode.httpStatus val errorResponse = CommonErrorResponse(errorCode) - logException(servletRequest, httpStatus, errorResponse, e) + log.info { convertExceptionLogMessage(servletRequest, httpStatus, errorResponse, e) } return ResponseEntity .status(httpStatus.value()) @@ -56,7 +56,7 @@ class GlobalExceptionHandler( val httpStatus: HttpStatus = errorCode.httpStatus val errorResponse = CommonErrorResponse(errorCode) - logException(servletRequest, httpStatus, errorResponse, e) + log.warn { convertExceptionLogMessage(servletRequest, httpStatus, errorResponse, e) } return ResponseEntity .status(httpStatus.value()) @@ -74,28 +74,26 @@ class GlobalExceptionHandler( val httpStatus: HttpStatus = errorCode.httpStatus val errorResponse = CommonErrorResponse(errorCode) - logException(servletRequest, httpStatus, errorResponse, e) + log.warn { convertExceptionLogMessage(servletRequest, httpStatus, errorResponse, e) } return ResponseEntity .status(httpStatus.value()) .body(errorResponse) } - private fun logException( + private fun convertExceptionLogMessage( servletRequest: HttpServletRequest, httpStatus: HttpStatus, errorResponse: CommonErrorResponse, exception: Exception - ) { + ): String { val actualException: Exception? = if (errorResponse.message == exception.message) null else exception - val logMessage = messageConverter.convertToErrorResponseMessage( + return messageConverter.convertToErrorResponseMessage( servletRequest = servletRequest, httpStatus = httpStatus, responseBody = errorResponse, exception = actualException ) - - log.warn { logMessage } } }