private static void FormatException(Exception ex, StringBuilder sb, ExceptionKind kind)
{
sb.AppendFormat("<tr><th>{0}:</th><td>`{1}`</td></tr>\r\n", KindToString(kind), ex.GetType().Name);
sb.AppendFormat("<tr><th>Message:</th><td>`{0}`</td></tr>\r\n", ex.Message);
sb.AppendFormat("<tr><th>Call stack:</th><td><pre>{0}</pre></td></tr>\r\n", ex.StackTrace);
if (ex.InnerException != null)
{
FormatException(ex.InnerException, sb, ExceptionKind.Inner);
}
if (ex is ReflectionTypeLoadException)
{
foreach (Exception e in ((ReflectionTypeLoadException)ex).LoaderExceptions)
{
FormatException(e, sb, ExceptionKind.LoaderException);
}
}
}