Posted By

ctrlbr34k on 03/31/11


Tagged

exception


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

cybermax


Exception management


 / Published in: C#
 

Extension class for Exception to display all inner messages

  1. public static string InnerMessages(this Exception exception)
  2. {
  3. var sb = new StringBuilder();
  4.  
  5. sb.AppendLine(exception.Message);
  6. while (exception.InnerException != null)
  7. {
  8. exception = exception.InnerException;
  9. sb.AppendLine(exception.Message);
  10. }
  11.  
  12. return sb.ToString();
  13. }

Report this snippet  

You need to login to post a comment.