【auth】整理auth的异常

pull/3/head
fengshuonan 2021-02-08 10:23:25 +08:00
parent 7499b60000
commit d00f963142
3 changed files with 5 additions and 11 deletions

View File

@ -1,6 +1,5 @@
package cn.stylefeng.roses.kernel.auth.api.enums;
import cn.hutool.core.util.StrUtil;
import cn.stylefeng.roses.kernel.auth.api.exception.AuthException;
import lombok.Getter;
@ -63,8 +62,7 @@ public enum DataScopeTypeEnum {
}
}
}
String userTip = StrUtil.format(DATA_SCOPE_ERROR.getUserTip(), code);
throw new AuthException(DATA_SCOPE_ERROR, userTip);
throw new AuthException(DATA_SCOPE_ERROR, code);
}
}

View File

@ -1,5 +1,6 @@
package cn.stylefeng.roses.kernel.auth.api.exception;
import cn.hutool.core.util.StrUtil;
import cn.stylefeng.roses.kernel.auth.api.constants.AuthConstants;
import cn.stylefeng.roses.kernel.rule.exception.AbstractExceptionEnum;
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
@ -12,12 +13,8 @@ import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
*/
public class AuthException extends ServiceException {
public AuthException(String errorCode, String userTip) {
super(AuthConstants.AUTH_MODULE_NAME, errorCode, userTip);
}
public AuthException(AbstractExceptionEnum exception, String userTip) {
super(AuthConstants.AUTH_MODULE_NAME, exception.getErrorCode(), userTip);
public AuthException(AbstractExceptionEnum exception, Object... params) {
super(AuthConstants.AUTH_MODULE_NAME, exception.getErrorCode(), StrUtil.format(exception.getUserTip(), params));
}
public AuthException(AbstractExceptionEnum exception) {

View File

@ -201,8 +201,7 @@ public class AuthServiceImpl implements AuthServiceApi {
// 6. 校验用户是否异常(不是正常状态)
if (!UserStatusEnum.ENABLE.getCode().equals(userValidateInfo.getUserStatus())) {
String userTip = StrUtil.format(AuthExceptionEnum.USER_STATUS_ERROR.getErrorCode(), UserStatusEnum.getCodeMessage(userValidateInfo.getUserStatus()));
throw new AuthException(AuthExceptionEnum.USER_STATUS_ERROR.getErrorCode(), userTip);
throw new AuthException(AuthExceptionEnum.USER_STATUS_ERROR, UserStatusEnum.getCodeMessage(userValidateInfo.getUserStatus()));
}
// 7. 获取LoginUser用于用户的缓存