plusone-commons 修改了 BaseException

This commit is contained in:
zhouxy108 2023-09-09 18:19:58 +08:00
parent b870684fea
commit 208d7c93c9
10 changed files with 55 additions and 55 deletions

View File

@ -11,29 +11,29 @@ public class BizException extends BaseException {
@java.io.Serial
private static final long serialVersionUID = -5524759033245815405L;
public static final int DEFAULT_ERROR_CODE = 4000000;
public static final String DEFAULT_ERROR_CODE = "4000000";
public BizException(int code, String msg) {
public BizException(String code, String msg) {
super(code, msg);
}
public BizException(int code, Throwable cause) {
public BizException(String code, Throwable cause) {
super(code, cause);
}
public BizException(int code, String msg, Throwable cause) {
public BizException(String code, String msg, Throwable cause) {
super(code, msg, cause);
}
public BizException(String msg) {
super(DEFAULT_ERROR_CODE, msg);
public static BizException of(String msg) {
return new BizException(DEFAULT_ERROR_CODE, msg);
}
public BizException(Throwable cause) {
super(DEFAULT_ERROR_CODE, cause);
public static BizException of(Throwable cause) {
return new BizException(DEFAULT_ERROR_CODE, cause);
}
public BizException(String msg, Throwable cause) {
super(DEFAULT_ERROR_CODE, msg, cause);
public static BizException of(String msg, Throwable cause) {
return new BizException(DEFAULT_ERROR_CODE, msg, cause);
}
}

View File

@ -14,7 +14,7 @@ public class DataNotExistException extends BizException {
@java.io.Serial
private static final long serialVersionUID = 6536955800679703111L;
public static final int ERROR_CODE = 4110100;
public static final String ERROR_CODE = "4110100";
public DataNotExistException() {
super(ERROR_CODE, "数据不存在");

View File

@ -18,7 +18,7 @@ public class DataOperationResultException extends SysException {
@java.io.Serial
private static final long serialVersionUID = -9220765735990318186L;
public static final int ERROR_CODE = 4110200;
public static final String ERROR_CODE = "4110200";
public DataOperationResultException() {
super(ERROR_CODE, "数据操作结果不符合预期");

View File

@ -6,29 +6,29 @@ public class SysException extends BaseException {
@java.io.Serial
private static final long serialVersionUID = 8821240827443168118L;
public static final int DEFAULT_ERROR_CODE = 5000000;
public static final String DEFAULT_ERROR_CODE = "5000000";
public SysException(int code, String msg) {
public SysException(String code, String msg) {
super(code, msg);
}
public SysException(int code, Throwable cause) {
public SysException(String code, Throwable cause) {
super(code, cause);
}
public SysException(int code, String msg, Throwable cause) {
public SysException(String code, String msg, Throwable cause) {
super(code, msg, cause);
}
public SysException(String msg) {
super(DEFAULT_ERROR_CODE, msg);
public static SysException of(String msg) {
return new SysException(DEFAULT_ERROR_CODE, msg);
}
public SysException(Throwable cause) {
super(DEFAULT_ERROR_CODE, cause);
public static SysException of(Throwable cause) {
return new SysException(DEFAULT_ERROR_CODE, cause);
}
public SysException(String msg, Throwable cause) {
super(DEFAULT_ERROR_CODE, msg, cause);
public static SysException of(String msg, Throwable cause) {
return new SysException(DEFAULT_ERROR_CODE, msg, cause);
}
}

View File

@ -14,28 +14,28 @@ public class UserOperationException extends BizException {
@java.io.Serial
private static final long serialVersionUID = 4371055414421991940L;
public static final int DEFAULT_ERROR_CODE = 4040600;
public static final String DEFAULT_ERROR_CODE = "4040600";
public UserOperationException(String msg) {
super(DEFAULT_ERROR_CODE, msg);
}
public UserOperationException(String msg, Throwable cause) {
super(DEFAULT_ERROR_CODE, msg, cause);
}
public UserOperationException(int code, String msg) {
public UserOperationException(String code, String msg) {
super(code, msg);
}
public UserOperationException(int code, Throwable cause) {
public UserOperationException(String code, Throwable cause) {
super(code, cause);
}
public UserOperationException(int code, String msg, Throwable cause) {
public UserOperationException(String code, String msg, Throwable cause) {
super(code, msg, cause);
}
public static UserOperationException of(String msg) {
return new UserOperationException(DEFAULT_ERROR_CODE, msg);
}
public static UserOperationException of(String msg, Throwable cause) {
return new UserOperationException(DEFAULT_ERROR_CODE, msg, cause);
}
/**
* 无效的操作
*
@ -52,7 +52,7 @@ public class UserOperationException extends BizException {
* @return 异常对象
*/
public static UserOperationException invalidOperation(String msg) {
return new UserOperationException(4040604, msg);
return new UserOperationException("4040604", msg);
}
}

View File

@ -186,7 +186,7 @@ public class FastDFSUtil {
var sha512Hex = new BigInteger(1, result).toString(16);
return Objects.requireNonNull(sha512Hex);
} catch (NoSuchAlgorithmException e) {
throw new SysException(e);
throw SysException.of(e);
}
}
}

View File

@ -10,13 +10,13 @@ public class AccountLoginException extends BizException {
@java.io.Serial
private static final long serialVersionUID = -3040996790739138556L;
private static final int DEFAULT_ERR_CODE = 4030000;
private static final String DEFAULT_ERR_CODE = "4030000";
private AccountLoginException() {
super(DEFAULT_ERR_CODE, "用户登录异常");
}
private AccountLoginException(int code, String message) {
private AccountLoginException(String code, String message) {
super(code, message);
}
@ -25,7 +25,7 @@ public class AccountLoginException extends BizException {
}
public static AccountLoginException accountNotExistException(String msg) {
return new AccountLoginException(4030101, msg);
return new AccountLoginException("4030101", msg);
}
public static AccountLoginException otpErrorException() {
@ -33,7 +33,7 @@ public class AccountLoginException extends BizException {
}
public static AccountLoginException otpErrorException(String msg) {
return new AccountLoginException(4030501, msg);
return new AccountLoginException("4030501", msg);
}
public static AccountLoginException otpNotExistsException() {
@ -41,7 +41,7 @@ public class AccountLoginException extends BizException {
}
public static AccountLoginException otpNotExistsException(String msg) {
return new AccountLoginException(4030502, msg);
return new AccountLoginException("4030502", msg);
}
public static AccountLoginException passwordErrorException() {
@ -49,6 +49,6 @@ public class AccountLoginException extends BizException {
}
public static AccountLoginException passwordErrorException(String msg) {
return new AccountLoginException(4030200, msg);
return new AccountLoginException("4030200", msg);
}
}

View File

@ -12,46 +12,46 @@ public class AccountRegisterException extends BizException {
private static final long serialVersionUID = 7580245181633370195L;
public AccountRegisterException() {
this(4020000, "用户注册错误");
this("4020000", "用户注册错误");
}
public AccountRegisterException(String message) {
this(4020000, message);
this("4020000", message);
}
public AccountRegisterException(Throwable cause) {
super(4020000, cause);
super("4020000", cause);
}
public AccountRegisterException(int code, String message) {
public AccountRegisterException(String code, String message) {
super(code, message);
}
public AccountRegisterException(int code, Throwable cause) {
public AccountRegisterException(String code, Throwable cause) {
super(code, cause);
}
public static AccountRegisterException emailOrMobilePhoneRequiredException() {
return new AccountRegisterException(4020300, "邮箱和手机号应至少绑定一个");
return new AccountRegisterException("4020300", "邮箱和手机号应至少绑定一个");
}
public static AccountRegisterException usernameAlreadyExists(String username) {
return new AccountRegisterException(4020400, String.format("用户名 %s 已存在", username));
return new AccountRegisterException("4020400", String.format("用户名 %s 已存在", username));
}
public static AccountRegisterException emailAlreadyExists(String value) {
return new AccountRegisterException(4020500, String.format("邮箱 %s 已存在", value));
return new AccountRegisterException("4020500", String.format("邮箱 %s 已存在", value));
}
public static AccountRegisterException mobilePhoneAlreadyExists(String value) {
return new AccountRegisterException(4020600, String.format("手机号 %s 已存在", value));
return new AccountRegisterException("4020600", String.format("手机号 %s 已存在", value));
}
public static AccountRegisterException codeErrorException() {
return new AccountRegisterException(4020701, "校验码错误");
return new AccountRegisterException("4020701", "校验码错误");
}
public static AccountRegisterException codeNotExistsException() {
return new AccountRegisterException(4020702, "校验码不存在或已过期");
return new AccountRegisterException("4020702", "校验码不存在或已过期");
}
}

View File

@ -11,7 +11,7 @@ public class UnsupportedPrincipalTypeException extends BizException {
private static final long serialVersionUID = 5207757290868470762L;
public static final int ERR_CODE = 4040201;
public static final String ERR_CODE = "4040201";
private static final String DEFAULT_ERROR_MSG = "不支持的 PrincipalType";
public UnsupportedPrincipalTypeException() {

View File

@ -59,7 +59,7 @@ public class AuthenticationInfo<T> {
if (this.metadata.containsKey(key)) {
return this.metadata.get(key);
}
throw new BizException(String.format("不存在 key 为 \"%s\"的元数据。", key));
throw BizException.of(String.format("不存在 key 为 \"%s\"的元数据。", key));
}
public OptionalDouble getMetadataAsDouble(String key) {