diff --git a/bubble-core/src/main/java/cn/fxbin/bubble/core/exception/InvalidEnumValueException.java b/bubble-core/src/main/java/cn/fxbin/bubble/core/exception/InvalidEnumValueException.java index 55140de1..b97b4a56 100644 --- a/bubble-core/src/main/java/cn/fxbin/bubble/core/exception/InvalidEnumValueException.java +++ b/bubble-core/src/main/java/cn/fxbin/bubble/core/exception/InvalidEnumValueException.java @@ -10,12 +10,11 @@ * @version v1.0 * @since 2022/10/26 14:34 */ +@Getter public class InvalidEnumValueException extends ServiceException{ - @Getter private int errcode; - @Getter private String errmsg; public InvalidEnumValueException() { diff --git a/bubble-core/src/main/java/cn/fxbin/bubble/core/exception/ServiceException.java b/bubble-core/src/main/java/cn/fxbin/bubble/core/exception/ServiceException.java index 96d5aab6..30e5d7d9 100644 --- a/bubble-core/src/main/java/cn/fxbin/bubble/core/exception/ServiceException.java +++ b/bubble-core/src/main/java/cn/fxbin/bubble/core/exception/ServiceException.java @@ -12,14 +12,11 @@ * @version v1.0 * @since 2020/3/23 11:05 */ +@Getter public class ServiceException extends RuntimeException { - private static final long serialVersionUID = 7366961732679791481L; - - @Getter private int errcode; - @Getter private String errmsg; public ServiceException(String errmsg) { @@ -40,6 +37,12 @@ public ServiceException(Result result) { this.errmsg = result.getErrmsg(); } + public ServiceException(ResultCode resultCode) { + super(resultCode.getMsg()); + this.errcode = resultCode.getCode(); + this.errmsg = resultCode.getMsg(); + } + public ServiceException(ResultCode resultCode, String errmsg, Object... args) { super(LoggerMessageFormat.format(errmsg, args)); this.errcode = resultCode.getCode(); diff --git a/bubble-core/src/main/java/cn/fxbin/bubble/core/exception/UtilException.java b/bubble-core/src/main/java/cn/fxbin/bubble/core/exception/UtilException.java index 12f76da9..b38f3761 100644 --- a/bubble-core/src/main/java/cn/fxbin/bubble/core/exception/UtilException.java +++ b/bubble-core/src/main/java/cn/fxbin/bubble/core/exception/UtilException.java @@ -1,6 +1,7 @@ package cn.fxbin.bubble.core.exception; import cn.fxbin.bubble.core.logging.LoggerMessageFormat; +import cn.fxbin.bubble.core.model.ResultCode; import lombok.Getter; /** @@ -10,12 +11,11 @@ * @version v1.0 * @since 2020/3/23 17:53 */ +@Getter public class UtilException extends ServiceException { - @Getter private int errcode; - @Getter private String errmsg; public UtilException(String errmsg) { @@ -24,6 +24,12 @@ public UtilException(String errmsg) { this.errmsg = errmsg; } + public UtilException(ResultCode resultCode) { + super(resultCode.getMsg()); + this.errcode = resultCode.getCode(); + this.errmsg = resultCode.getMsg(); + } + public UtilException(Integer errcode, String errmsg) { super(errmsg); this.errcode = errcode;