title: Reusable Try/Catch Block
body: <p>I wrote the following method thinking that it would allow me to pass in a method call to be wrapped within a try catch. I'm trying to avoid placing the same try/catch boiler plate coding throughout my application. I already have 20 plus calls and by the time we are finished there will be hundreds of calls. </p>
  
  <pre><code>protected T CallRepository&lt;T&gt;(T repositoryMethod)
  {
      try
      {
          return repositoryMethod;
      }
      catch (Exception ex)
      {
          logger.Error(ex);
          throw new DatabaseException();
      }
  }
  </code></pre>
  
  <p>The calling method looks like:</p>
  
  <pre><code>var results = CallRepository&lt;VisitLogDTO&gt;(visitLogRepository.AddVisit(visitLogDTO));
  </code></pre>
  
  <p>I didn't realize at first that this isn't working as expected. What is happening is the results are being wrapped in the try/catch but not the call to the method. If I get a database error or any error from the visitLogRepository then I the original error and not the new DatabaseExeception.</p>
  
  <p>Any help would be greatly appreciated.</p>