From f41b89059a2a5b943e0a25564d49e93dc9ee188a Mon Sep 17 00:00:00 2001 From: timerix Date: Mon, 26 Sep 2022 17:31:48 +0600 Subject: [PATCH] removed blank catch --- .../StringBuilderExtentions.cs | 25 +++++++------------ 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/Ben.Demystifier/StringBuilderExtentions.cs b/src/Ben.Demystifier/StringBuilderExtentions.cs index 196dd8c..36050a5 100644 --- a/src/Ben.Demystifier/StringBuilderExtentions.cs +++ b/src/Ben.Demystifier/StringBuilderExtentions.cs @@ -9,26 +9,19 @@ public static class StringBuilderExtentions { public static StringBuilder AppendDemystified(this StringBuilder builder, Exception exception) { - try - { - var stackTrace = new EnhancedStackTrace(exception); + var stackTrace = new EnhancedStackTrace(exception); - builder.Append(exception.GetType()); - if (!string.IsNullOrEmpty(exception.Message)) builder.Append(": ").Append(exception.Message); - builder.Append(Environment.NewLine); + builder.Append(exception.GetType()); + if (!string.IsNullOrEmpty(exception.Message)) builder.Append(": ").Append(exception.Message); + builder.Append(Environment.NewLine); - if (stackTrace.FrameCount > 0) stackTrace.AppendTo(builder); + stackTrace.AppendTo(builder); - if (exception is AggregateException aggEx) - foreach (var ex in EnumerableIList.Create(aggEx.InnerExceptions)) - builder.AppendInnerException(ex); + if (exception is AggregateException aggEx) + foreach (var ex in EnumerableIList.Create(aggEx.InnerExceptions)) + builder.AppendInnerException(ex); - if (exception.InnerException is not null) builder.AppendInnerException(exception.InnerException); - } - catch - { - // Processing exceptions shouldn't throw exceptions; if it fails - } + if (exception.InnerException is not null) builder.AppendInnerException(exception.InnerException); return builder; }