UndeclaredThrowableException异常

先来看看他的API说明

Thrown by a method invocation on a proxy instance if its invocation handler’s invoke method throws a checked exception (a Throwable that is not assignable to RuntimeException or Error) that is not assignable to any of the exception types declared in the throws clause of the method that was invoked on the proxy instance and dispatched to the invocation handler.

An UndeclaredThrowableException instance contains the undeclared checked exception that was thrown by the invocation handler, and it can be retrieved with the getUndeclaredThrowable() method. UndeclaredThrowableException extends RuntimeException, so it is an unchecked exception that wraps a checked exception.

As of release 1.4, this exception has been retrofitted to conform to the general purpose exception-chaining mechanism. The “undeclared checked exception that was thrown by the invocation handler” that may be provided at construction time and accessed via the getUndeclaredThrowable() method is now known as the cause, and may be accessed via the Throwable.getCause() method, as well as the aforementioned “legacy method.”

翻译下:

抛出一个方法调用代理实例的调用处理程序的调用方法抛出一个检查异常(Throwable,不分配RuntimeException或错误),不分配任何的异常类型中声明抛出条款的代理实例上调用方法,并分派到调用处理程序。

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

从版本1.4开始,这个异常已经进行了修改,以符合通用异常链接机制。“调用处理程序抛出的未声明的检查异常”可以在构建时提供,并通过getUndeclaredThrowable()方法访问,现在称为原因,可以通过Throwable.getCause()方法以及前面提到的“遗留方法”访问。

查看下JDK的java doc:

JDK的java doc是这么解释UndeclaredThrowableException的:如果代理实例的调用处理程序的 invoke 方法抛出一个经过检查的异常(不可分配给 RuntimeException 或 Error 的 Throwable),且该异常不可分配给该方法的throws子局声明的任何异常类,则由代理实例上的方法调用抛出此异常。

下面上swagger测试的结果


在看下IDEA中反馈回给我们的信息


最后检查是


XML文件中的<query id = "delete">里面的标签与mapper中的不符合,导致程序运行时,无法正确找到对应的SQL语句,导致出现的异常 

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • packagetestexcrpltiom; importjava.text.ParseException; im...
    猿学阅读 1,555评论 0赞 2
  • 闲来翻译了一篇官方的JNI Tips,网上看到的翻译版本要么是时间久了不同步了,要么翻译的过于生硬,看得我怀疑自己...
    生活简单些阅读 2,020评论 1赞 4
  • 1. Java基础部分 基础部分的顺序:基本语法,类相关的语法,内部类的语法,继承相关的语法,异常的语法,线程的语...
    子非鱼_t_阅读 35,386评论 18赞 399
  • 和爸爸的沟通相信会是很多人的心病。 妈妈总是感情丰富,对于我所做的事情,她不一定理解,但她更多地是凭借情感做判断:...
    拉面的第二人生阅读 784评论 0赞 48
  • 异地恋的无奈就在于 “眼看着你很忙却给不了任何陪伴” “想安安静静呆在你身边却无能为力” “听着电话两端的叹息什么...
    云霞shinging阅读 220评论 0赞 0

友情链接更多精彩内容