Exception 'java.lang.Exception' is never thrown in the method less
阿新 • • 發佈:2018-12-13
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 層進行處理