How to know which exception is thrown

前端 未结 4 871
清歌不尽
清歌不尽 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:30

    You can 1) dig through all the code in doSomething() and everything it calls to see the exception handling and what RuntimeExceptions can be thrown, or 2) take of the catch (Exception e) and wait for it to fail. This is the problem that checked exceptions attempted to overcome by making a strongly-typed declaration in method signatures about what exceptions must be handled as a result of calling the method.

提交回复
热议问题