Skip to content

Commit

Permalink
feat: Objectoptimisticlockingfailureexception 핸들러 추가 (#1073)
Browse files Browse the repository at this point in the history
* feat: 낙관적 락 충돌 예외 핸들러 추가

* chore: 에러 코드 변경

* chore: 에러 메시지 변경
  • Loading branch information
Soundbar91 authored Nov 24, 2024
1 parent 43cfc1a commit 0a47f33
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -188,6 +189,16 @@ public ResponseEntity<Object> handleNoHandlerFoundException(
return buildErrorResponse(HttpStatus.NOT_FOUND, "유효하지 않은 API 경로입니다.");
}

@ExceptionHandler(ObjectOptimisticLockingFailureException.class)
public ResponseEntity<Object> handleOptimisticLockException(
HttpServletRequest request,
ObjectOptimisticLockingFailureException e
) {
log.warn(e.getMessage());
requestLogging(((ServletWebRequest)request).getRequest());
return buildErrorResponse(HttpStatus.CONFLICT, "이미 처리된 요청입니다.");
}

@ExceptionHandler(Exception.class)
public ResponseEntity<Object> handleException(
HttpServletRequest request,
Expand Down

0 comments on commit 0a47f33

Please sign in to comment.