mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
add methods
This commit is contained in:
parent
ec60393c28
commit
db9d3fc721
@ -128,11 +128,22 @@ public class ExceptionUtil {
|
|||||||
/**
|
/**
|
||||||
* 将消息包装为运行时异常并抛出
|
* 将消息包装为运行时异常并抛出
|
||||||
*
|
*
|
||||||
* @param message 异常消息
|
* @param message 错误消息模板,被替换的部分用 {} 表示
|
||||||
* @since 5.5.2
|
* @param params 参数
|
||||||
*/
|
*/
|
||||||
public static void wrapRuntimeAndThrow(final String message) {
|
public static void wrapRuntimeAndThrow(final String message, final Object... params) {
|
||||||
throw new RuntimeException(message);
|
throw new RuntimeException(StrUtil.format(message, params));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将消息包装为运行时异常并抛出
|
||||||
|
*
|
||||||
|
* @param cause 异常原因
|
||||||
|
* @param message 错误消息模板,被替换的部分用 {} 表示
|
||||||
|
* @param params 参数
|
||||||
|
*/
|
||||||
|
public static void wrapRuntimeAndThrow(final Throwable cause, final String message, final Object... params) {
|
||||||
|
throw new RuntimeException(StrUtil.format(message, params), cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -425,7 +436,6 @@ public class ExceptionUtil {
|
|||||||
* 此方法通过调用{@link Throwable#getCause()} 直到没有cause为止,如果异常本身没有cause,返回异常本身<br>
|
* 此方法通过调用{@link Throwable#getCause()} 直到没有cause为止,如果异常本身没有cause,返回异常本身<br>
|
||||||
* 传入null返回也为null
|
* 传入null返回也为null
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @param throwable 异常对象,可能为null
|
* @param throwable 异常对象,可能为null
|
||||||
* @return 最尾端异常,传入null参数返回也为null
|
* @return 最尾端异常,传入null参数返回也为null
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user