fix: 为部分异常捕捉添加错误日志展示
This commit is contained in:
parent
322256cc5a
commit
f375432e7d
@ -45,21 +45,20 @@ public class LimitInterceptor {
|
|||||||
@Before("@annotation(limitPointAnnotation)")
|
@Before("@annotation(limitPointAnnotation)")
|
||||||
public void interceptor(LimitPoint limitPointAnnotation) {
|
public void interceptor(LimitPoint limitPointAnnotation) {
|
||||||
LimitTypeEnums limitTypeEnums = limitPointAnnotation.limitType();
|
LimitTypeEnums limitTypeEnums = limitPointAnnotation.limitType();
|
||||||
String name = limitPointAnnotation.name();
|
|
||||||
String key;
|
String key;
|
||||||
int limitPeriod = limitPointAnnotation.period();
|
int limitPeriod = limitPointAnnotation.period();
|
||||||
int limitCount = limitPointAnnotation.limit();
|
int limitCount = limitPointAnnotation.limit();
|
||||||
switch (limitTypeEnums) {
|
if (limitTypeEnums == LimitTypeEnums.CUSTOMER) {
|
||||||
case CUSTOMER:
|
key = limitPointAnnotation.key();
|
||||||
key = limitPointAnnotation.key();
|
} else {
|
||||||
break;
|
key = limitPointAnnotation.key() + IpUtils
|
||||||
default:
|
.getIpAddress(((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
|
||||||
key = limitPointAnnotation.key() + IpUtils
|
|
||||||
.getIpAddress(((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
|
|
||||||
}
|
}
|
||||||
ImmutableList<String> keys = ImmutableList.of(StringUtils.join(limitPointAnnotation.prefix(), key));
|
ImmutableList<String> keys = ImmutableList.of(StringUtils.join(limitPointAnnotation.prefix(), key));
|
||||||
try {
|
try {
|
||||||
Number count = redisTemplate.execute(limitScript, keys, limitCount, limitPeriod);
|
Number count = redisTemplate.execute(limitScript, keys, limitCount, limitPeriod);
|
||||||
|
assert count != null;
|
||||||
log.info("限制请求{}, 当前请求{},缓存key{}", limitCount, count.intValue(), key);
|
log.info("限制请求{}, 当前请求{},缓存key{}", limitCount, count.intValue(), key);
|
||||||
//如果缓存里没有值,或者他的值小于限制频率
|
//如果缓存里没有值,或者他的值小于限制频率
|
||||||
if (count.intValue() >= limitCount) {
|
if (count.intValue() >= limitCount) {
|
||||||
@ -72,6 +71,7 @@ public class LimitInterceptor {
|
|||||||
} catch (ServiceException e) {
|
} catch (ServiceException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
log.error("限流异常", e);
|
||||||
throw new ServiceException(ResultCode.ERROR);
|
throw new ServiceException(ResultCode.ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,7 @@ public class PreventDuplicateSubmissionsInterceptor {
|
|||||||
} catch (ServiceException e) {
|
} catch (ServiceException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
log.error("防重复提交拦截器异常", e);
|
||||||
throw new ServiceException(ResultCode.ERROR);
|
throw new ServiceException(ResultCode.ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,6 +96,7 @@ public class VerificationServiceImpl implements VerificationService {
|
|||||||
} catch (ServiceException e) {
|
} catch (ServiceException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
log.error("生成验证码失败", e);
|
||||||
throw new ServiceException(ResultCode.ERROR);
|
throw new ServiceException(ResultCode.ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user