{{ message }}
Add non-recursive trace to empty catch blocks in StructuredTraceSource.TraceScope#27622
Open
euxaristia wants to merge 1 commit into
Open
Add non-recursive trace to empty catch blocks in StructuredTraceSource.TraceScope#27622euxaristia wants to merge 1 commit into
StructuredTraceSource.TraceScope#27622euxaristia wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves diagnostics in StructuredTraceSource.TraceScope by adding non-recursive System.Diagnostics.Trace.WriteLine output in previously empty catch blocks that swallowed exceptions from ScopeTracer construction.
Changes:
- Replaced three empty
catch { }blocks inTraceScopeoverloads withcatch (Exception e)blocks. - Added
System.Diagnostics.Trace.WriteLine(...)calls to emit a diagnostic message whenScopeTracerconstruction fails.
Comment on lines
+440
to
+443
Comment on lines
+457
to
+460
| catch (Exception e) | ||
| { | ||
| System.Diagnostics.Trace.WriteLine("ScopeTracer(string,object) threw: " + e.Message); | ||
| } |
Comment on lines
+474
to
+477
…ce.TraceScope` The `TraceScope` methods contained empty catch blocks that silently swallowed exceptions from the `ScopeTracer` constructor. Use `System.Diagnostics.Trace.WriteLine` for diagnostics since the class's own trace methods would cause recursion here.
5134f29 to
ab756f9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

PR Summary
Add
System.Diagnostics.Trace.WriteLinecalls to three empty catch blocks inStructuredTraceSource.TraceScopemethods that were silently swallowing exceptions from theScopeTracerconstructor.PR Context
The
TraceScopeoverloads contained empty catch blocks that caught all exceptions from theScopeTracerconstructor. While the original intent was to ensure trace methods never throw, silently swallowing all exceptions hides infrastructure failures. UsingSystem.Diagnostics.Trace.WriteLine(which bypasses PSTraceSource) provides diagnostics without risk of recursion.PR Checklist