title: How to catch all exceptions at class level in CSharp?
body: <p>I have a class like:</p>
  
  <pre><code>class SampleRepositoryClass
  {
      void MethodA()
      {
          try
          {
              //do something
          }
          catch(Exception ex)
          {
              LogError(ex);
              throw ex;
          }        
      }
  
      void MethodB(int a, int b)
      {
          try
          {
              //do something
          }
          catch(Exception ex)
          {
              LogError(ex);
              throw ex;
          }
      }
  
      List&lt;int&gt; MethodC(int userId)
      {
          try
          {
              //do something
          }
          catch(Exception ex)
          {
              LogError(ex);
              throw ex;
          }
      }
  }
  </code></pre>
  
  <p>In above example, you can see that in each methods (MethodA, MethodB, MethodC) have try...catch blocks to log the errors and then throw to higher level. </p>
  
  <p>Imagine that when my Repository class might have more than hundred methods and in each method I have try...catch block even if there is only single line of code. </p>
  
  <p>Now, my intention is to reduce these repetitive exception logging code and log all the exceptions at class level instead of method level.</p>