优化redis的连接失败的错误提示

This commit is contained in:
xxx 2023-09-05 16:28:13 +08:00
parent 06da295d58
commit 8cf5bc0a6e

View File

@ -17,6 +17,7 @@ package xyz.playedu.api.controller;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.RedisConnectionFailureException;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.validation.ObjectError;
import org.springframework.web.HttpRequestMethodNotSupportedException;
@ -48,6 +49,11 @@ public class ExceptionController {
return JsonResponse.error(e.getMessage(), 1);
}
@ExceptionHandler(RedisConnectionFailureException.class)
public JsonResponse serviceExceptionHandler(RedisConnectionFailureException e) {
return JsonResponse.error("redis服务连接失败", 500);
}
@ExceptionHandler(HttpMessageNotReadableException.class)
public JsonResponse serviceExceptionHandler(HttpMessageNotReadableException e) {
log.error("error", e);