优化
This commit is contained in:
@@ -15,6 +15,7 @@ import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.validation.BindException;
|
||||
import org.springframework.validation.FieldError;
|
||||
import org.springframework.http.converter.HttpMessageNotReadableException;
|
||||
import org.springframework.dao.CannotAcquireLockException;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.MissingRequestHeaderException;
|
||||
import org.springframework.web.bind.MissingServletRequestParameterException;
|
||||
@@ -96,6 +97,14 @@ public class GlobalExceptionHandler {
|
||||
return failure(ResultCode.NOT_FOUND, ResultCode.NOT_FOUND.message(), request);
|
||||
}
|
||||
|
||||
@ExceptionHandler(CannotAcquireLockException.class)
|
||||
public ResponseEntity<ApiResponse<Void>> handleCannotAcquireLock(
|
||||
CannotAcquireLockException exception, HttpServletRequest request) {
|
||||
log.warn("Database lock acquisition conflict requestId={} traceId={}",
|
||||
CorrelationContext.requestId(request), CorrelationContext.traceId(request));
|
||||
return failure(ResultCode.CONFLICT, "资源正在处理中,请稍后重试", request);
|
||||
}
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
public ResponseEntity<ApiResponse<Void>> handleUnexpected(Exception exception, HttpServletRequest request) {
|
||||
log.error("Unhandled request failure requestId={} traceId={}",
|
||||
|
||||
Reference in New Issue
Block a user