Skip to content

Commit 66df06f

Browse files
authored
CSHARP-5449: Retry does not work with BulkWrite operations within the session (#1598)
1 parent f788452 commit 66df06f

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

src/MongoDB.Driver/ClientBulkWriteException.cs

+19
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,25 @@ public ClientBulkWriteException(
4545
WriteErrors = writeErrors;
4646
PartialResult = partialResult;
4747
WriteConcernErrors = writeConcernErrors;
48+
49+
if (innerException is MongoException innerMongoException)
50+
{
51+
foreach (var errorLabel in innerMongoException.ErrorLabels)
52+
{
53+
AddErrorLabel(errorLabel);
54+
}
55+
}
56+
57+
if (writeConcernErrors != null)
58+
{
59+
foreach (var writeConcernError in writeConcernErrors)
60+
{
61+
foreach (var errorLabel in writeConcernError.ErrorLabels)
62+
{
63+
AddErrorLabel(errorLabel);
64+
}
65+
}
66+
}
4867
}
4968

5069
/// <summary>

tests/MongoDB.Driver.Tests/UnifiedTestOperations/Matchers/UnifiedErrorMatcher.cs

-5
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,6 @@ private void AssertErrorContains(Exception actualException, string expectedSubst
114114

115115
private void AssertErrorLabelsContain(Exception actualException, IEnumerable<string> expectedErrorLabels)
116116
{
117-
if (actualException is ClientBulkWriteException bulkWriteException)
118-
{
119-
actualException = bulkWriteException.InnerException;
120-
}
121-
122117
var mongoException = actualException.Should().BeAssignableTo<MongoException>().Subject;
123118
mongoException.ErrorLabels.Should().Contain(expectedErrorLabels);
124119
}

0 commit comments

Comments
 (0)