¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.dromara.common.redis.handler; |
| | | |
| | | import cn.hutool.http.HttpStatus; |
| | | import com.baomidou.lock.exception.LockFailureException; |
| | | import jakarta.servlet.http.HttpServletRequest; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.dromara.common.core.domain.R; |
| | | import org.springframework.web.bind.annotation.ExceptionHandler; |
| | | import org.springframework.web.bind.annotation.RestControllerAdvice; |
| | | |
| | | /** |
| | | * Rediså¼å¸¸å¤çå¨ |
| | | * |
| | | * @author AprilWind |
| | | */ |
| | | @Slf4j |
| | | @RestControllerAdvice |
| | | public class RedisExceptionHandler { |
| | | |
| | | /** |
| | | * åå¸å¼éLock4jå¼å¸¸ |
| | | */ |
| | | @ExceptionHandler(LockFailureException.class) |
| | | public R<Void> handleLockFailureException(LockFailureException e, HttpServletRequest request) { |
| | | String requestURI = request.getRequestURI(); |
| | | log.error("è·åé失败äº'{}',åçLock4jå¼å¸¸." + requestURI, e.getMessage()); |
| | | return R.fail(HttpStatus.HTTP_UNAVAILABLE, "ä¸å¡å¤çä¸ï¼è¯·ç¨ååè¯..."); |
| | | } |
| | | |
| | | } |