Skip to content

Commit b144327

Browse files
author
Emile Joubert
committed
Capture first connection attempt as inner exception in BrokerUnreachableException
1 parent 670e6a1 commit b144327

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

projects/client/RabbitMQ.Client/src/client/api/ConnectionFactory.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,8 @@ public virtual IConnection CreateConnection(int maxRedirects)
313313
if (conn != null) {
314314
return conn;
315315
}
316-
throw new BrokerUnreachableException(connectionAttempts, connectionErrors);
316+
Exception Inner = connectionErrors[Endpoint] as Exception;
317+
throw new BrokerUnreachableException(connectionAttempts, connectionErrors, Inner);
317318
}
318319

319320
///<summary>Create a connection to the specified endpoint

projects/client/RabbitMQ.Client/src/client/exceptions/BrokerUnreachableException.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,12 @@ public class BrokerUnreachableException: IOException
7474

7575
///<summary>Construct a BrokerUnreachableException. Expects
7676
///maps as per the description of the ConnectionAttempts and
77-
///ConnectionErrors properties.</summary>
77+
///ConnectionErrors properties. The inner exception is associated
78+
///with only one connection attempt.</summary>
7879
public BrokerUnreachableException(IDictionary connectionAttempts,
79-
IDictionary connectionErrors)
80-
: base("None of the specified endpoints were reachable")
80+
IDictionary connectionErrors,
81+
Exception Inner)
82+
: base("None of the specified endpoints were reachable", Inner)
8183
{
8284
m_connectionAttempts = connectionAttempts;
8385
m_connectionErrors = connectionErrors;

0 commit comments

Comments
 (0)