Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Updated tests and changelog
  • Loading branch information
jamescrosswell committed Mar 14, 2025
commit b2a029b57ed1bfdb9d706a39be74d53dceeb9e6f
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Features

- User Feedback can now be captured without errors/exceptions. Note that these APIs replace the older UserFeedback APIs, which have now been marked as obsolete (and will be removed in a future major version bump) ([#3981](https://github.com/getsentry/sentry-dotnet/pull/3981))
- Exception.HResult is now included in the mechanism data for all exceptions ([#4029](https://github.com/getsentry/sentry-dotnet/pull/4029))

Check failure on line 8 in CHANGELOG.md

View workflow job for this annotation

GitHub Actions / danger / danger

The changelog entry seems to be part of an already released section `## 5.3.0`. Consider moving the entry to the `## Unreleased` section, please.

Check failure on line 8 in CHANGELOG.md

View workflow job for this annotation

GitHub Actions / danger / danger

The changelog entry seems to be part of an already released section `## 5.3.0`. Consider moving the entry to the `## Unreleased` section, please.

### Fixes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@
Type: generic,
Handled: true,
Synthetic: false,
IsExceptionGroup: false
IsExceptionGroup: false,
Data: {
HResult: 0x80131500
}
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@
Type: generic,
Handled: true,
Synthetic: false,
IsExceptionGroup: false
IsExceptionGroup: false,
Data: {
HResult: 0x80131500
}
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@
Type: generic,
Handled: true,
Synthetic: false,
IsExceptionGroup: false
IsExceptionGroup: false,
Data: {
HResult: 0x80131500
}
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@
Synthetic: false,
IsExceptionGroup: false,
Data: {
details: Do work always throws.
details: Do work always throws.,
HResult: 0x80131500
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@
Synthetic: false,
IsExceptionGroup: false,
Data: {
details: Do work always throws.
details: Do work always throws.,
HResult: 0x80131500
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
Synthetic: false,
IsExceptionGroup: false,
ExceptionId: 2,
ParentId: 0
ParentId: 0,
Data: {
HResult: 0x80131500
}
}
},
{
Expand All @@ -20,7 +23,10 @@
Synthetic: false,
IsExceptionGroup: false,
ExceptionId: 1,
ParentId: 0
ParentId: 0,
Data: {
HResult: 0x80131500
}
}
},
{
Expand All @@ -33,7 +39,8 @@
IsExceptionGroup: true,
ExceptionId: 0,
Data: {
foo: bar
foo: bar,
HResult: 0x80131500
}
}
}
Expand Down
17 changes: 14 additions & 3 deletions test/Sentry.Tests/Internals/MainExceptionProcessorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ private class Fixture
private readonly Fixture _fixture = new();

[Fact]
public void Process_ExceptionsWithoutData_MechanismDataIsEmpty()
public void Process_ExceptionsWithoutData_MechanismDataIsMinimal()
{
var sut = _fixture.GetSut();
var evt = new SentryEvent();
Expand All @@ -21,7 +21,12 @@ public void Process_ExceptionsWithoutData_MechanismDataIsEmpty()
sut.Process(ex, evt);

var sentryException = evt.SentryExceptions!.Single();
Assert.Empty(sentryException.Mechanism!.Data);

// All managed exceptions has an HResult, at a bare minimum (which we store in the Mechanism.Data)
sentryException.Mechanism!.Data.Should().BeEquivalentTo(new Dictionary<string, string>()
{
["HResult"] = "0x80131500" // The default value of HRESULT for managed exceptions (COR_E_EXCEPTION)
});
}

[Fact]
Expand Down Expand Up @@ -109,7 +114,13 @@ public void CreateSentryException_DataHasObjectAsKey_ItemIgnored()

var actual = sut.CreateSentryExceptions(ex).Single();

Assert.Null(actual.Mechanism);
// The custom data won't be added, but the mechanism data will still contain an HResult.
// We add the HResult for all exceptions
actual.Mechanism!.Data.Should().BeEquivalentTo(new Dictionary<string, string>()
{
["HResult"] = "0x80131500" // The default value of HRESULT for managed exceptions (COR_E_EXCEPTION)
});

}

[Fact]
Expand Down
Loading