Last active
August 29, 2015 14:19
-
-
Save gowon/6e9f6b2dd7fd87ba4873 to your computer and use it in GitHub Desktop.
Grabbing all exception messages from inner exceptions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Text; | |
| public static class ExceptionExtensions | |
| { | |
| public static string GetAllMessages(this Exception ex) | |
| { | |
| var message = new StringBuilder(); | |
| for (var e = ex; e != null; e = e.InnerException) | |
| message.AppendLine(e.Message); | |
| return message.ToString(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment