From 7051c5f644a32c2c03052666a2b095717f34db72 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Mon, 27 Oct 2014 13:00:09 -0400 Subject: [PATCH 1/2] Removed `FormatStack` in favor of exception's `.ToString()`. Removed redundant `traceObject` null check. --- loggr-dotnet/Utility/ExceptionFormatter.cs | 31 ++-------------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/loggr-dotnet/Utility/ExceptionFormatter.cs b/loggr-dotnet/Utility/ExceptionFormatter.cs index ef9e258..c785f7c 100644 --- a/loggr-dotnet/Utility/ExceptionFormatter.cs +++ b/loggr-dotnet/Utility/ExceptionFormatter.cs @@ -90,42 +90,15 @@ public static string Format(Exception ex, object traceObject) res += "
"; res += "Traced Object(s)
"; res += "
"; - if (traceObject != null) - { - res += ObjectDumper.DumpObject(traceObject, 1); - } - else - { - res += "Not specified
"; - } + res += ObjectDumper.DumpObject(traceObject, 1); } res += "
"; res += "Stack Trace
"; res += "
"; - - FormatStack(ex, ref res); + res += string.IsNullOrEmpty(ex.ToString()) ? "No stack trace" : ex.ToString(); return res; } - - protected static void FormatStack(Exception Ex, ref string Buffer) - { - if (Ex.InnerException != null) - { - FormatStack(Ex.InnerException, ref Buffer); - } - Buffer += string.Format("[{0}: {1}]
", Ex.GetType().ToString(), Ex.Message); - if (Ex.StackTrace != null) - { - Buffer += HttpUtility.HtmlEncode(Ex.StackTrace).Replace(Environment.NewLine, "
"); - } - else - { - Buffer += "No stack trace"; - } - Buffer += "
"; - Buffer += "
"; - } } } \ No newline at end of file From ccb09d9af491bbb4c2f5a289f2421e3ec1aed42c Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 29 Oct 2014 15:39:27 -0400 Subject: [PATCH 2/2] Wrap exception's `ToString()` in html `
` tags for
 better formatting in the loggr UI

---
 loggr-dotnet/Utility/ExceptionFormatter.cs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/loggr-dotnet/Utility/ExceptionFormatter.cs b/loggr-dotnet/Utility/ExceptionFormatter.cs
index c785f7c..2605b78 100644
--- a/loggr-dotnet/Utility/ExceptionFormatter.cs
+++ b/loggr-dotnet/Utility/ExceptionFormatter.cs
@@ -96,7 +96,7 @@ public static string Format(Exception ex, object traceObject)
             res += "
"; res += "Stack Trace
"; res += "
"; - res += string.IsNullOrEmpty(ex.ToString()) ? "No stack trace" : ex.ToString(); + res += string.IsNullOrEmpty(ex.ToString()) ? "No stack trace" : string.Format("
{0}
", ex.ToString()); return res; }