Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static class ExceptionExtensions
- {
- public static IEnumerable<Exception> FlatException(this Exception exception)
- {
- var innerException = exception;
- do
- {
- yield return innerException;
- innerException = innerException.InnerException;
- }
- while (innerException != null);
- }
- public static string FullExceptionMessage(this Exception exception)
- {
- var messages = exception.FlatException().Select(x => x.Message);
- var flatMessage = string.Join("\n", messages);
- return flatMessage;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment