title: Unreachable code, but reachable with an exception
body: <p>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 successfully created, then returning <code>true</code>.</p>
  
  <p>My understanding of control flow is as follows:</p>
  
  <p><code>command.ExecuteNonQuery()</code> is documented to throw an <code>Invalid​Operation​Exception</code> when "a method call is invalid for the object's current state". Therefore, if that would happen, execution of the <code>try</code> block would stop, the <code>finally</code> block would be executed, then would execute the <code>return false;</code> at the bottom.</p>
  
  <p>However, my IDE claims that the <code>return false;</code> is unreachable code. And it seems to be true, I can remove it and it compiles without any complaints. However, for me it looks as if there would be no return value for the code path where the mentioned exception is thrown.</p>
  
  <pre><code>private static bool createRecord(String table,
                                   IDictionary&lt;String,String&gt; data,
                                   System.Data.IDbConnection conn,
                                   OdbcTransaction trans) {
  
      [... some other code ...]
  
      int returnValue = 0;
      try {
          command.CommandText = sb.ToString();
          returnValue = command.ExecuteNonQuery();
  
          return returnValue == 1;
      } finally {
          command.Dispose();
      }
  
      return false;
  }
  </code></pre>
  
  <p>What is my error of understanding here?</p>