title: Refactoring exception handling
body: <p>In one of my classes I have a call to a repository which has some error handling on it. I would like to refactor the error handling code because it is quite repetitive and the only thing that really changes is the message.</p>
  
  <p>My code currently looks something like this:</p>
  
  <pre><code>public IList&lt;User&gt; GetUser()
  {
      try
      {
          return _repository.GetUsers();
      }
      catch (WebException ex)
      {
          ErrorMessages.Add("...");
          _logger.ErrorException("...", ex);
      }
      catch (SoapException ex)
      {
         ErrorMessages.Add("...");
          _logger.ErrorException("...", ex);
      }
      ... etc
  }
  </code></pre>
  
  <p>I could replace those lines in my catch block with a call to another method which takes an error message value and a logger message value. However I suppose I could also do this using an Action&lt;> parameter but I am very inexperienced at using Func&lt;> and Action&lt;> and don't really see what benefit I would have using one of those over a method.</p>
  
  <p>My question is really what is the best way to refactor this code and why does one way benefit over the other (as per my example above).</p>
  
  <p>Thanks for any help.</p>