generated from pricelees/issue-pr-template
refactor: GlobalExceptionHandler에서 커스텀 예외는 INFO 로그로 기록하도록 수정
This commit is contained in:
parent
1902fc6f7c
commit
979623a670
@ -30,7 +30,7 @@ class GlobalExceptionHandler(
|
|||||||
val httpStatus: HttpStatus = errorCode.httpStatus
|
val httpStatus: HttpStatus = errorCode.httpStatus
|
||||||
val errorResponse = CommonErrorResponse(errorCode)
|
val errorResponse = CommonErrorResponse(errorCode)
|
||||||
|
|
||||||
logException(servletRequest, httpStatus, errorResponse, e)
|
log.info { convertExceptionLogMessage(servletRequest, httpStatus, errorResponse, e) }
|
||||||
|
|
||||||
return ResponseEntity
|
return ResponseEntity
|
||||||
.status(httpStatus.value())
|
.status(httpStatus.value())
|
||||||
@ -56,7 +56,7 @@ class GlobalExceptionHandler(
|
|||||||
val httpStatus: HttpStatus = errorCode.httpStatus
|
val httpStatus: HttpStatus = errorCode.httpStatus
|
||||||
val errorResponse = CommonErrorResponse(errorCode)
|
val errorResponse = CommonErrorResponse(errorCode)
|
||||||
|
|
||||||
logException(servletRequest, httpStatus, errorResponse, e)
|
log.warn { convertExceptionLogMessage(servletRequest, httpStatus, errorResponse, e) }
|
||||||
|
|
||||||
return ResponseEntity
|
return ResponseEntity
|
||||||
.status(httpStatus.value())
|
.status(httpStatus.value())
|
||||||
@ -74,28 +74,26 @@ class GlobalExceptionHandler(
|
|||||||
val httpStatus: HttpStatus = errorCode.httpStatus
|
val httpStatus: HttpStatus = errorCode.httpStatus
|
||||||
val errorResponse = CommonErrorResponse(errorCode)
|
val errorResponse = CommonErrorResponse(errorCode)
|
||||||
|
|
||||||
logException(servletRequest, httpStatus, errorResponse, e)
|
log.warn { convertExceptionLogMessage(servletRequest, httpStatus, errorResponse, e) }
|
||||||
|
|
||||||
return ResponseEntity
|
return ResponseEntity
|
||||||
.status(httpStatus.value())
|
.status(httpStatus.value())
|
||||||
.body(errorResponse)
|
.body(errorResponse)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun logException(
|
private fun convertExceptionLogMessage(
|
||||||
servletRequest: HttpServletRequest,
|
servletRequest: HttpServletRequest,
|
||||||
httpStatus: HttpStatus,
|
httpStatus: HttpStatus,
|
||||||
errorResponse: CommonErrorResponse,
|
errorResponse: CommonErrorResponse,
|
||||||
exception: Exception
|
exception: Exception
|
||||||
) {
|
): String {
|
||||||
val actualException: Exception? = if (errorResponse.message == exception.message) null else exception
|
val actualException: Exception? = if (errorResponse.message == exception.message) null else exception
|
||||||
|
|
||||||
val logMessage = messageConverter.convertToErrorResponseMessage(
|
return messageConverter.convertToErrorResponseMessage(
|
||||||
servletRequest = servletRequest,
|
servletRequest = servletRequest,
|
||||||
httpStatus = httpStatus,
|
httpStatus = httpStatus,
|
||||||
responseBody = errorResponse,
|
responseBody = errorResponse,
|
||||||
exception = actualException
|
exception = actualException
|
||||||
)
|
)
|
||||||
|
|
||||||
log.warn { logMessage }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user