From 474f7ad50d6c4436448fe6800c27af8f1d476c38 Mon Sep 17 00:00:00 2001 From: mzr <1562242162@qq.com> Date: Mon, 18 Nov 2024 18:53:36 +0800 Subject: [PATCH] =?UTF-8?q?refactor(redis):=20=E4=BC=98=E5=8C=96=20RedisSe?= =?UTF-8?q?rvice=20=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 引入自定义异常类 CustomException- 使用 ErrorUtils 工具类处理错误信息 - 在 catch块中抛出 CustomException,便于错误追踪和处理 --- .../java/com/yb/lb/webapp/redis/service/RedisService.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crm-common/src/main/java/com/yb/lb/webapp/redis/service/RedisService.java b/crm-common/src/main/java/com/yb/lb/webapp/redis/service/RedisService.java index 044be86..a6f2ffe 100644 --- a/crm-common/src/main/java/com/yb/lb/webapp/redis/service/RedisService.java +++ b/crm-common/src/main/java/com/yb/lb/webapp/redis/service/RedisService.java @@ -1,5 +1,7 @@ package com.yb.lb.webapp.redis.service; +import com.yb.lb.common.exception.CustomException; +import com.yb.lb.common.utils.ErrorUtils; import com.yb.lb.webapp.redis.entity.ObjectTranscoder; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -343,7 +345,7 @@ public class RedisService { } catch (Exception e) { returnResource(jedis); e.printStackTrace(); - return null; + throw new CustomException("redis-exp:" + e.getMessage(), ErrorUtils.ERROR); } }