title: Why don't .NET exceptions work against an interface rather than a base class?
body: <p>The .Net framework try-catch implementation only allows you to catch types which inherit off the base class "System.Exception". Why could this not have been an interface such as "System.IException"?</p>
  
  <h1>Use case</h1>
  
  <p>We use a custom base class in each API that inherits off System.Exception. This is only thrown once an exception has been logged and therefore we can easily avoid re-logging by something like:</p>
  
  <pre><code>try
  {
      // Do something.
  }
  catch (LoggedException)
  {
      // Already logged so just rethrow.
      throw;
  }
  catch (Exception ex)
  {
      // TODO: Log exception.
      throw new LoggedException("Failed doing something.", ex);
  }
  </code></pre>
  
  <p>This is great until you want a custom exception that inherits off another system exception type such as System.FormatException</p>
  
  <p>The only way to now handle both of these is to have two custom base types and duplicate every catch statement.</p>
  
  <h1>Refactoring</h1>
  
  <p>If the .net framework just simply looked for something such as System.IException then you could simply have a custom exception interface such as CompanyName.ILoggedException, inheriting System.IException which all your custom exception types implement. Therefore your new catch code would look something like:</p>
  
  <pre><code>try
  {
      // Do something.
  }
  catch (ILoggedException)
  {
      // Already logged so just rethrow.
      throw;
  }
  catch (IException ex)
  {
      // TODO: Log exception.
      throw new CustomException("Failed doing something.", ex);
  }
  </code></pre>
  
  <p>Is there a practical reason the framework is implemented like this? Or would this be something to request in a future version of the .Net framework?</p>