Exception 'java.lang.Exception' is never thrown in the method less

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/mingyundezuoan/article/details/82937725

Exception ‘java.lang.Exception’ is never thrown in the method less


异常描述

  • 使用 IDEA 开发过程中发现已有方法上抛出异常,但是异常代码的颜色是浅灰色的,鼠标移到代码上提示上述异常

Exception ‘java.lang.Exception’ is never thrown in the method less… (Ctrl+F1)
This inspection reports exceptions that are declared in a method’s signature but never thrown by the method itself or its implementations/derivatives. Since this inspection requires global code analysis, it is only available in batch inspection mode. A limited version for use in editor highlighting is available as General | Redundant throws declaration.


异常分析

  • 方法中不需要抛出异常,因为没有需要抛出异常的代码
  • 在 call() 方法上显示的抛出异常,但是 call() 方法内部却并无异常抛出,也没有会出现异常的代码内容

异常反思

  • 开发过程中从底层编码开始需要向上抛出异常,异常交给 Controller 层进行处理

猜你喜欢

转载自blog.csdn.net/mingyundezuoan/article/details/82937725
今日推荐