title: Wrapping logging within an exception object
body: <p>I currently have this class that another programmer in my team coded:  </p>
  
  <pre><code>public static class SoapExecuter
  {
      private static readonly ILog logger;
  
      public static Exception ExecuterException { get; private set; }
  
      public static bool IsSoapException
      {
          get 
          {
              if (ExecuterException == null)
                  return false;
  
              return ExecuterException.GetType() == typeof(SoapException);
          }
      }
  
      public static bool Execute(Action action)
      {
          ExecuterException = null;
          bool passed = false;
  
          try
          {
              action();
              passed = true;
          }
          catch (SoapException se)
          {
              ExecuterException = se;
              logger.log(se);
          }
          catch (Exception ex)
          {
              ExecuterException = ex;  
              logger.log(ex);
          }
  
          return passed;
      }
  }
  </code></pre>
  
  <p>This is not very idiomatic and I would like to change it to something that happens within the try...catch clause.<br>
  Is there a way to not violate DRY and still stay within the idioms the language offers?<br>
  Of course I can inherit from the SoapException and log it but I'll have to catch a SoapException and create a new exception object that wraps it and then throw it only to be silenced one level above.<br>
  Any idea guys?</p>