异常非空判断

This commit is contained in:
2023-09-04 11:25:21 +08:00
parent 217afe5e01
commit 3177b40b4f
2 changed files with 4 additions and 7 deletions

View File

@@ -58,9 +58,10 @@ public class GlobalBusinessExceptionHandler {
logService.recodeBusinessExceptionLog(businessException, httpServletRequest, businessException.getMessage());
//判断方法上是否有自定义注解,做特殊处理
Method method = ReflectCommonUtil.getMethod(businessException);
if(method.isAnnotationPresent(ReturnMsg.class)){
log.info("存在自定义注解");
return HttpResultUtil.assembleResult(businessException.getCode(), null, StrFormatter.format("{}",businessException.getMessage()));
if (!Objects.isNull(method)){
if(method.isAnnotationPresent(ReturnMsg.class)){
return HttpResultUtil.assembleResult(businessException.getCode(), null, StrFormatter.format("{}",businessException.getMessage()));
}
}
return HttpResultUtil.assembleBusinessExceptionResult(businessException, null, operate);
}
@@ -232,7 +233,6 @@ public class GlobalBusinessExceptionHandler {
//判断方法上是否有自定义注解,做特殊处理
Method method = ReflectCommonUtil.getMethod(exception);
if(method.isAnnotationPresent(ReturnMsg.class)){
log.info("存在自定义注解");
return HttpResultUtil.assembleResult(code, null, StrFormatter.format("{}",exceptionCause));
}
return HttpResultUtil.assembleResult(code, null, StrFormatter.format("{}{}{}", ReflectCommonUtil.getMethodDescribeByException(tempException), StrUtil.C_COMMA, exceptionCause));

View File

@@ -108,9 +108,6 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, User> impleme
addSendMessage(phone,vcode,msgTemplate,sendSmsResponse);
throw new BusinessException(e.getMessage());
}
if (Objects.isNull(sendSmsResponse)){
throw new BusinessException(UserResponseEnum.MESSAGE_SEND_FAIL);
}
return sendSmsResponse.getCode();
}