Module java.base

Class UndeclaredThrowableException

所有已实现的接口:
Serializable

public class UndeclaredThrowableException extends RuntimeException
如果代理实例的调用处理程序的invoke方法抛出一个已检查异常(一个不能赋值给RuntimeExceptionErrorThrowable),而该异常又不能赋值给代理实例上调用并分派给调用处理程序的方法的throws子句中声明的任何异常类型,则会抛出此异常。

UndeclaredThrowableException实例包含调用处理程序抛出的未声明的已检查异常,可以使用getUndeclaredThrowable()方法检索该异常。 UndeclaredThrowableException扩展了RuntimeException,因此它是一个未检查的异常,用于包装已检查的异常。

自从:
1.3
参见:
  • Constructor Details

    • UndeclaredThrowableException

      public UndeclaredThrowableException(Throwable undeclaredThrowable)
      使用指定的Throwable构造一个UndeclaredThrowableException
      参数:
      undeclaredThrowable - 被抛出的未声明的已检查异常
    • UndeclaredThrowableException

      public UndeclaredThrowableException(Throwable undeclaredThrowable, String s)
      使用指定的Throwable和详细消息构造一个UndeclaredThrowableException
      参数:
      undeclaredThrowable - 被抛出的未声明的已检查异常
      s - 详细消息
  • Method Details

    • getUndeclaredThrowable

      public Throwable getUndeclaredThrowable()
      返回包装在此UndeclaredThrowableException中的Throwable实例,可能为null
      API注释:
      此方法早于通用异常链接功能。现在,Throwable.getCause()方法是获取此信息的首选方法。
      返回:
      被抛出的未声明的已检查异常