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; }