diff --git a/src/main/java/com/youlai/system/common/exception/BusinessException.java b/src/main/java/com/youlai/system/common/exception/BusinessException.java index a9f96205..df423497 100644 --- a/src/main/java/com/youlai/system/common/exception/BusinessException.java +++ b/src/main/java/com/youlai/system/common/exception/BusinessException.java @@ -2,11 +2,12 @@ package com.youlai.system.common.exception; import com.youlai.system.common.result.IResultCode; import lombok.Getter; +import org.slf4j.helpers.MessageFormatter; /** * 自定义业务异常 * - * @author haoxr + * @author Ray Hao * @since 2022/7/31 */ @Getter @@ -19,17 +20,19 @@ public class BusinessException extends RuntimeException { this.resultCode = errorCode; } - public BusinessException(String message){ - super(message); - } - - public BusinessException(String message, Throwable cause){ + public BusinessException(String message, Throwable cause) { super(message, cause); } - public BusinessException(Throwable cause){ + public BusinessException(Throwable cause) { super(cause); } + public BusinessException(String message, Object... args) { + super(formatMessage(message, args)); + } + private static String formatMessage(String message, Object... args) { + return MessageFormatter.arrayFormat(message, args).getMessage(); + } }