refactor(redis): 优化 RedisService 异常处理
- 引入自定义异常类 CustomException- 使用 ErrorUtils 工具类处理错误信息 - 在 catch块中抛出 CustomException,便于错误追踪和处理
This commit is contained in:
		
							parent
							
								
									6bbc08daa5
								
							
						
					
					
						commit
						474f7ad50d
					
				|  | @ -1,5 +1,7 @@ | ||||||
| package com.yb.lb.webapp.redis.service; | 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 com.yb.lb.webapp.redis.entity.ObjectTranscoder; | ||||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||||
|  | @ -343,7 +345,7 @@ public class RedisService { | ||||||
|         } catch (Exception e) { |         } catch (Exception e) { | ||||||
|             returnResource(jedis); |             returnResource(jedis); | ||||||
|             e.printStackTrace(); |             e.printStackTrace(); | ||||||
|             return null; |             throw new CustomException("redis-exp:" + e.getMessage(), ErrorUtils.ERROR); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue