Exception management


/ Published in: C#
Save to your folder(s)

Extension class for Exception to display all inner messages


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.