模块 wjybxx.base

类 ExceptionUtils

java.lang.Object
cn.wjybxx.base.ex.ExceptionUtils

public class ExceptionUtils extends Object
异常工具类

这里部分修改自Commons-Lang3,为避免依赖,我们选择拷贝代码。 我用的最多的就是rethrow(Throwable)...

作者:
wjybxx date - 2024/1/3
  • 构造器详细资料

    • ExceptionUtils

      public ExceptionUtils()
  • 方法详细资料

    • getRootCause

      public static Throwable getRootCause(Throwable throwable)
      获取异常的根
    • getThrowableList

      public static List<Throwable> getThrowableList(Throwable throwable)
      展开异常信息
    • isChecked

      public static boolean isChecked(Throwable throwable)
      是否是受检异常
    • isUnchecked

      public static boolean isUnchecked(Throwable throwable)
      是否是非受检异常 -- 通常指运行时异常
    • rethrow

      public static <R> R rethrow(Throwable throwable)
      抛出原始异常,消除编译时警告
      类型参数:
      R - 方法正常执行的返回值类型
    • throwUnchecked

      public static <T extends Throwable> T throwUnchecked(T throwable)
      如果异常是非受检异常,则直接抛出,否则返回异常对象。