title: NUnit: Write ex.Message to Console when exception nature is unknown
body: <p>I have a Selenium test written with the help of <strong>C#</strong> and <strong>NUnit framework</strong>. During my test there are possible numerous exceptions that might be thrown and test will eventually fails. I would like to get someone's help on what will be the appropriate approach to write to the console this exception message where I don't exactly know what exception will be thrown. See my current code example below:</p>
  
  <pre><code>[Test] //NUnit attribute
  public void SomeTest(){
  piece of code that might throw: 
  NoSuchElementException 
  TimeOutException 
  NullPointerException 
  ElementNotVisibleException and many many others
  }
  
  [TearDown] //NUnit attribute
  public void AfterEveryTest(){
  if((TestContext.CurrentContext.Result.Outcome.Equals(ResultState.Failure))||(TestContext.CurrentContext.Result.Outcome.Equals(ResultState.Error)))
  {
  NUnitException ex = new NUnitException ();
  Console.WriteLine(ex.Message);
  }
  }
  </code></pre>
  
  <p>When I run this code and for instance NoSuchElementException is thrown, Visual Studio NUnit Console Runner displays correct message (for instance <code>OpenQA.Selenium.NoSuchElementException : Could not find element by: By.XPath://div[@class='name']</code> where the console writes the message <code>Exception of type 'NUnit.Framework.Internal.NUnitException' was thrown.</code> What will be the correct way to modify the code so console gets absolutely the same error message as NUnit Console Runner. Is there any global Exception class or instance that will pass the same message to Console.WriteLine()?     </p>