title: C#: Overriding ToString() method for custom exceptions
body: <p>I have a custom exception class which contains some additional fields. I want these to be written out in the <code>ToString()</code> method, but if I implement my own <code>ToString()</code>, I loose some other useful stuff (like writing the exception type name, the inner exception data and the stack trace). </p>
  
  <p>What is the best way/pattern to implement your own <code>ToString()</code> method for such exceptions? Ideally it should reuse the existing mechanism, but be formatted in way similar to the default <code>ToString()</code> implementation. </p>
  
  <p>UPDATE: prepending or appending my custom fields to the base.ToString() text isn't ideal IMHO, for example</p>
  
  <pre><code>PimTool.Utilities.OERestServiceUnavailableException: test ---&gt; System.InvalidOperationException: inner message
     --- End of inner exception stack trace ---
     at PimTool.Tests.Services.OE.OERestClientTests.ExceptionsLogging() in D:\svn\NewPimTool\PimTool.Tests\Services\OE\OERestClientTests.cs:line 178, 
     StatusCode=0, message='test', requestId='535345'
  </code></pre>
  
  <p>means the custom fields are written at the end of the (potentially long) exception description.
  On the other hand, I want the exception type to be the first information written in the description.</p>
  
  <p>UPDATE 2: I've implemented a solution for this, look for my own answer below.</p>