From ced76d125e90fc0be71d3be0605170606e197ace Mon Sep 17 00:00:00 2001 From: Luke Bakken Date: Wed, 1 May 2024 08:52:52 -0700 Subject: [PATCH] Better exception message when a continuation times out --- .../RabbitMQ.Client/client/impl/AsyncRpcContinuations.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/projects/RabbitMQ.Client/client/impl/AsyncRpcContinuations.cs b/projects/RabbitMQ.Client/client/impl/AsyncRpcContinuations.cs index bf1bed00a8..4f73677e44 100644 --- a/projects/RabbitMQ.Client/client/impl/AsyncRpcContinuations.cs +++ b/projects/RabbitMQ.Client/client/impl/AsyncRpcContinuations.cs @@ -68,7 +68,8 @@ public AsyncRpcContinuation(TimeSpan continuationTimeout, CancellationToken canc { // Cancellation was successful, does this mean we set a TimeoutException // in the same manner as BlockingCell used to - tcs.SetException(new TimeoutException("TODO LRB rabbitmq/rabbitmq-dotnet-client#1347")); + string msg = $"operation '{GetType().FullName}' timed out after {continuationTimeout}"; + tcs.TrySetException(new TimeoutException(msg)); } }, _tcs); #else @@ -79,7 +80,8 @@ public AsyncRpcContinuation(TimeSpan continuationTimeout, CancellationToken canc { // Cancellation was successful, does this mean we set a TimeoutException // in the same manner as BlockingCell used to - tcs.SetException(new TimeoutException("TODO LRB rabbitmq/rabbitmq-dotnet-client#1347")); + string msg = $"operation '{GetType().FullName}' timed out after {continuationTimeout}"; + tcs.TrySetException(new TimeoutException(msg)); } }, state: _tcs, useSynchronizationContext: false); #endif @@ -109,7 +111,7 @@ public ConfiguredTaskAwaitable.ConfiguredTaskAwaiter GetAwaiter() public virtual void HandleChannelShutdown(ShutdownEventArgs reason) { - _tcs.SetException(new OperationInterruptedException(reason)); + _tcs.TrySetException(new OperationInterruptedException(reason)); } protected virtual void Dispose(bool disposing)