diff --git a/Microsoft.Azure.Cosmos/src/Handler/AbstractRetryHandler.cs b/Microsoft.Azure.Cosmos/src/Handler/AbstractRetryHandler.cs index cd8796074c..af812b0abb 100644 --- a/Microsoft.Azure.Cosmos/src/Handler/AbstractRetryHandler.cs +++ b/Microsoft.Azure.Cosmos/src/Handler/AbstractRetryHandler.cs @@ -53,6 +53,10 @@ public override async Task SendAsync( throw; } + catch (OperationCanceledException ex) + { + throw new CosmosOperationCanceledException(ex, request.Trace); + } finally { request.OnBeforeSendRequestActions -= retryPolicyInstance.OnBeforeSendRequest; diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/ClientConfigurationDiagnosticTest.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/ClientConfigurationDiagnosticTest.cs index 742d6df4ab..ef7efd9f16 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/ClientConfigurationDiagnosticTest.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/ClientConfigurationDiagnosticTest.cs @@ -154,10 +154,9 @@ public async Task VerifyDiagnosticsOrderTest() } catch (CosmosOperationCanceledException oce) { - IReadOnlyList children = ((CosmosTraceDiagnostics)oce.Diagnostics).Value.Children; - ITrace exceptionChild = children[^1]; - Assert.AreEqual("CosmosOperationCanceledException", exceptionChild.Name); - Assert.IsNotNull(exceptionChild.Data["Operation Cancelled Exception"]); + //check that the exception child exists in the trace diagnostics + Assert.IsTrue(oce.Diagnostics.ToString().Contains("CosmosOperationCanceledException")); + Assert.IsTrue(oce.Diagnostics.ToString().Contains("Operation Cancelled Exception")); } } }