32 lines
689 B
C#
32 lines
689 B
C#
using System;
|
|
using System.Text;
|
|
|
|
namespace AyaNova.Util
|
|
{
|
|
|
|
|
|
internal static class ExceptionUtil
|
|
{
|
|
|
|
/// <summary>
|
|
/// Extract and return exception message
|
|
/// Handles innermost exceptions level by level
|
|
/// </summary>
|
|
/// <param name="ex"></param>
|
|
/// <returns></returns>
|
|
public static string ExtractAllExceptionMessages(Exception ex)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
while (ex != null)
|
|
{
|
|
sb.AppendLine($"{ex.Source} -> {ex.Message}");
|
|
ex = ex.InnerException;
|
|
}
|
|
|
|
return sb.ToString();
|
|
}
|
|
|
|
|
|
}//eoc
|
|
|
|
}//eons |