新增异常实例化方式

This commit is contained in:
白茶清欢 2025-06-03 21:35:43 +08:00
parent ff96f647e6
commit 4a4e1a6a7a

View File

@ -21,6 +21,13 @@ public class CustomException extends RuntimeException {
this.message = message;
}
public CustomException(ICustomExceptionConfig iCustomExceptionConfig) {
this.code = iCustomExceptionConfig.getCode();
this.message = iCustomExceptionConfig.getMessage();
this.category = iCustomExceptionConfig.getCategory();
this.data = null;
}
// 根据code与
public CustomException(ICustomExceptionConfig iCustomExceptionConfig, Object data) {
this.code = iCustomExceptionConfig.getCode();
@ -31,7 +38,7 @@ public class CustomException extends RuntimeException {
public CustomException(String category, String code, Object data) {
this.category = category;
this.code = code;
this.message = HashMapCache.getInstance().getCodeMessage(category, code);
this.message = HashMapCache.getInstance().getMessage(category, code);
this.data = data;
}