diff --git a/src/main/java/in/koreatech/koin/global/exception/GlobalExceptionHandler.java b/src/main/java/in/koreatech/koin/global/exception/GlobalExceptionHandler.java index 9f1e28b65..700234e8e 100644 --- a/src/main/java/in/koreatech/koin/global/exception/GlobalExceptionHandler.java +++ b/src/main/java/in/koreatech/koin/global/exception/GlobalExceptionHandler.java @@ -13,6 +13,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatusCode; import org.springframework.http.ResponseEntity; +import org.springframework.orm.ObjectOptimisticLockingFailureException; import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; @@ -188,6 +189,16 @@ public ResponseEntity handleNoHandlerFoundException( return buildErrorResponse(HttpStatus.NOT_FOUND, "유효하지 않은 API 경로입니다."); } + @ExceptionHandler(ObjectOptimisticLockingFailureException.class) + public ResponseEntity handleOptimisticLockException( + HttpServletRequest request, + ObjectOptimisticLockingFailureException e + ) { + log.warn(e.getMessage()); + requestLogging(((ServletWebRequest)request).getRequest()); + return buildErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR, e.getMessage()); + } + @ExceptionHandler(Exception.class) public ResponseEntity handleException( HttpServletRequest request,