title: Recursive calls from a catch block
body: <p>I'm coding a method where an attempt to upload a document is wrapped within a Try/Catch block.</p>
  
  <p>If the attempt fails, I'm incrementing the Retry counter and recursively calling the same method.</p>
  
  <p>I'm not clear on the execution path in those cases where the 'Catch' block is hit. Initial tests show that the 'return null' statement is executed after that first recursive call executes. Perhaps the 'return null' statement needs to be within the Catch block but outside the retries&lt;3 loop?</p>
  
  <pre><code>public RssUploadDocOutput UploadInvoice(string filename, int retries)
          {
              var returnsOutput = new RssUploadDocOutput();
  
              GoogleSheetsCommand sscmd = new GoogleSheetsCommand("UploadDocument", ConnSheets);
              sscmd.CommandType = System.Data.CommandType.StoredProcedure;
              sscmd.Parameters.Add(new GoogleSheetsParameter("LocalFile", filename));
  
              //int retries = 0; removed 
  
              try
              {
               GoogleSheetsDataReader rdr = sscmd.ExecuteReader();
                 rdr.Read();
  
                  returnsOutput.ID = rdr[0].ToString();
                  [...]
                  returnsOutput.Weblink = rdr[6].ToString();
  
                  return returnsOutput;
              }
              catch (Exception ex)
              {
                  //retries++;
                  Logger.Instance.LogException(ex);
                  if (retries &lt; 3)
                  {
                      Thread.Sleep(1000 * retries);
                      UploadInvoice(filename, retries+1);
                  }
              }
              return null;
          }
  </code></pre>