public static string CollectExceptionMessages(Exception ex)
{
var sb = new StringBuilder();
var e = ex;
while (e != null)
{
sb.AppendLine(e.Message).AppendLine(e.StackTrace).AppendLine("-----------------");
e = e.InnerException;
}
return sb.ToString();
}
}