using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Bowin.Common.Utility { public static class ExceptionHelper { public static string GetFullExceptionMessage(this Exception ex) { string message = ex.Message + "|" + ex.StackTrace; if (ex.InnerException != null) { message += "\n\t" + GetFullExceptionMessage(ex.InnerException); } return message; } public static IEnumerable FindException(this Exception ex) where T : Exception { var result = new List(); if (ex is AggregateException) { result.AddRange(((AggregateException)ex).InnerExceptions.SelectMany(x => x.FindException())); } else { if (ex is T) { result.Add((T)ex); } if (ex.InnerException != null) { result.AddRange(ex.InnerException.FindException()); } } return result; } } }