How to know which exception is thrown

前端 未结 4 860
清歌不尽
清歌不尽 2021-02-03 11:29

I\'m doing a review for our codebase, and there are many statements like this:

try
{
   doSomething()
} catch (Exception e)
{

}

but I would l

4条回答
  •  野的像风
    2021-02-03 12:15

    Do you want to catch just compile-time exceptions or run-time exceptions as well? If you only want to catch the compile-time ones, just remove your current catch block - you'll immediately get error messages stating that certain exceptions aren't being caught. After you add one exception, you'll see error messages for others - you'll be able to finish catching all possible exceptions thrown by your code block.

提交回复
热议问题