diff --git a/kernel-d-pinyin/pinyin-api/src/main/java/cn/stylefeng/roses/kernel/pinyin/api/exception/PinyinException.java b/kernel-d-pinyin/pinyin-api/src/main/java/cn/stylefeng/roses/kernel/pinyin/api/exception/PinyinException.java index 7eb7f5aaa..ae70c0b0a 100644 --- a/kernel-d-pinyin/pinyin-api/src/main/java/cn/stylefeng/roses/kernel/pinyin/api/exception/PinyinException.java +++ b/kernel-d-pinyin/pinyin-api/src/main/java/cn/stylefeng/roses/kernel/pinyin/api/exception/PinyinException.java @@ -1,5 +1,6 @@ package cn.stylefeng.roses.kernel.pinyin.api.exception; +import cn.hutool.core.util.StrUtil; import cn.stylefeng.roses.kernel.pinyin.api.constants.PinyinConstants; import cn.stylefeng.roses.kernel.rule.exception.AbstractExceptionEnum; import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException; @@ -14,12 +15,12 @@ import lombok.Getter; @Getter public class PinyinException extends ServiceException { - public PinyinException(AbstractExceptionEnum exceptionEnum, String userTip) { - super(PinyinConstants.PINYIN_MODULE_NAME, exceptionEnum.getErrorCode(), userTip); - } - public PinyinException(AbstractExceptionEnum exceptionEnum) { super(PinyinConstants.PINYIN_MODULE_NAME, exceptionEnum); } + public PinyinException(AbstractExceptionEnum exception, Object... params) { + super(PinyinConstants.PINYIN_MODULE_NAME, exception.getErrorCode(), StrUtil.format(exception.getUserTip(), params)); + } + } diff --git a/kernel-d-pinyin/pinyin-sdk-pinyin4j/src/main/java/cn/stylefeng/roses/kernel/pinyin/PinyinServiceImpl.java b/kernel-d-pinyin/pinyin-sdk-pinyin4j/src/main/java/cn/stylefeng/roses/kernel/pinyin/PinyinServiceImpl.java index f4bd94b1f..5e82cfed9 100644 --- a/kernel-d-pinyin/pinyin-sdk-pinyin4j/src/main/java/cn/stylefeng/roses/kernel/pinyin/PinyinServiceImpl.java +++ b/kernel-d-pinyin/pinyin-sdk-pinyin4j/src/main/java/cn/stylefeng/roses/kernel/pinyin/PinyinServiceImpl.java @@ -1,6 +1,5 @@ package cn.stylefeng.roses.kernel.pinyin; -import cn.hutool.core.util.StrUtil; import cn.stylefeng.roses.kernel.pinyin.api.PinYinApi; import cn.stylefeng.roses.kernel.pinyin.api.exception.PinyinException; import net.sourceforge.pinyin4j.PinyinHelper; @@ -107,8 +106,7 @@ public class PinyinServiceImpl implements PinYinApi { } return finalPinyinString.toString(); } catch (BadHanyuPinyinOutputFormatCombination e1) { - String userTip = StrUtil.format(PARSE_ERROR.getUserTip(), e1.getMessage()); - throw new PinyinException(PARSE_ERROR, userTip); + throw new PinyinException(PARSE_ERROR, e1.getMessage()); } } @@ -182,8 +180,7 @@ public class PinyinServiceImpl implements PinYinApi { } } } catch (BadHanyuPinyinOutputFormatCombination e) { - String userTip = StrUtil.format(PARSE_ERROR.getUserTip(), e.getMessage()); - throw new PinyinException(PARSE_ERROR, userTip); + throw new PinyinException(PARSE_ERROR, e.getMessage()); } return hanyupinyin.toString();