Unreachable code, but reachable with an exception

前端 未结 9 1733
说谎
说谎 2020-12-28 11:22

This code is part of an application that reads from and writes to an ODBC connected database. It creates a record in the database and then checks if a record has been succes

9条回答
  •  余生分开走
    2020-12-28 11:45

    the finally block would be executed, then would execute the return false; at the bottom.

    Wrong. finally doesn't swallow the exception. It honors it and the exception will be thrown as normal. It will only execute the code in the finally before the block ends (with or without an exception).

    If you want the exception to be swallowed, you should use a catch block with no throw in it.

提交回复
热议问题