title: How get the error of ActiveRecord::Base.connection.execute?
body: <pre><code>  begin
  
      ActiveRecord::Base.transaction do
  
        // ...
        sanitized_sql = "INSERT INTO pinfo ..."
        ActiveRecord::Base.connection.execute(sanitized_sql)
  
      end
  
    rescue
  
      // how can I get the error?       
  
    end
  </code></pre>
  
  <p>In the webrick console, the error (<code>1967-07-16?00:00:00</code>) is shown as:</p>
  
  <blockquote>
    <p>EXECUTE (0.0ms)   ODBC::Error: 22008 (241) [unixODBC][FreeTDS][SQL Server]Syntax error converting datetime from character string.: INSERT INTO pinfo (birthdate) VALUES ('1967-07-16?00:00:00')
    EXECUTE (0.8ms)   IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION</p>
  </blockquote>
  
  <p>How can I get the above error message (<code>ODBC::Error: 22008 (241) ...</code>) raised from <code>ActiveRecord::Base.connection.execute</code> in <code>rescue</code>?</p>