@@ -125,21 +125,23 @@ public override RiakResult<IEnumerable<TResult>> UseDelayedConnection<TResult>(F
125125 {
126126 if ( retryAttempts < 0 )
127127 {
128- return RiakResult < IEnumerable < TResult > > . FromError ( ResultCode . NoRetries , "Unable to access a connection on the cluster." , false ) ;
128+ return RiakResult < IEnumerable < TResult > > . FromError ( ResultCode . NoRetries , "Unable to access a connection on the cluster (no more retries) ." , false ) ;
129129 }
130130
131131 if ( disposing )
132132 {
133133 return RiakResult < IEnumerable < TResult > > . FromError ( ResultCode . ShuttingDown , "System currently shutting down" , true ) ;
134134 }
135135
136+ var errorMessages = new List < string > ( ) ;
136137 var node = loadBalancer . SelectNode ( ) ;
137-
138138 if ( node != null )
139139 {
140140 var result = node . UseDelayedConnection ( useFun ) ;
141141 if ( ! result . IsSuccess )
142142 {
143+ errorMessages . Add ( result . ErrorMessage ) ;
144+
143145 if ( result . ResultCode == ResultCode . NoConnections )
144146 {
145147 Thread . Sleep ( RetryWaitTime ) ;
@@ -157,7 +159,8 @@ public override RiakResult<IEnumerable<TResult>> UseDelayedConnection<TResult>(F
157159 return result ;
158160 }
159161
160- return RiakResult < IEnumerable < TResult > > . FromError ( ResultCode . ClusterOffline , "Unable to access functioning Riak node" , true ) ;
162+ string msg = string . Format ( "Unable to access functioning Riak node, error(s): {0}" , string . Join ( ", " , errorMessages ) ) ;
163+ return RiakResult < IEnumerable < TResult > > . FromError ( ResultCode . ClusterOffline , msg , true ) ;
161164 }
162165
163166 protected override void Dispose ( bool disposing )
@@ -196,7 +199,7 @@ protected override TRiakResult UseConnection<TRiakResult>(
196199 {
197200 if ( retryAttempts < 0 )
198201 {
199- return onError ( ResultCode . NoRetries , "Unable to access a connection on the cluster." , false ) ;
202+ return onError ( ResultCode . NoRetries , "Unable to access a connection on the cluster (no more retries) ." , false ) ;
200203 }
201204
202205 if ( disposing )
@@ -207,9 +210,12 @@ protected override TRiakResult UseConnection<TRiakResult>(
207210 var node = loadBalancer . SelectNode ( ) ;
208211 if ( node != null )
209212 {
213+ var errorMessages = new List < string > ( ) ;
210214 var result = node . UseConnection ( useFun ) ;
211215 if ( ! result . IsSuccess )
212216 {
217+ errorMessages . Add ( result . ErrorMessage ) ;
218+
213219 TRiakResult nextResult = null ;
214220 if ( result . ResultCode == ResultCode . NoConnections )
215221 {
@@ -223,21 +229,29 @@ protected override TRiakResult UseConnection<TRiakResult>(
223229 nextResult = UseConnection ( useFun , onError , retryAttempts - 1 ) ;
224230 }
225231
226- // if the next result is successful then return that
227- if ( nextResult != null && nextResult . IsSuccess )
232+ if ( nextResult != null )
228233 {
229- return nextResult ;
234+ // if the next result is successful then return that
235+ if ( nextResult . IsSuccess )
236+ {
237+ return nextResult ;
238+ }
239+ else
240+ {
241+ errorMessages . Add ( nextResult . ErrorMessage ) ;
242+ }
230243 }
231244
232245 // otherwise we'll return the result that we had at this call to make sure that
233246 // the correct/initial error is shown
234- return onError ( result . ResultCode , result . ErrorMessage , result . NodeOffline ) ;
247+ string errorMessage = string . Join ( ", " , errorMessages ) ;
248+ return onError ( result . ResultCode , errorMessage , result . NodeOffline ) ;
235249 }
236250
237251 return ( TRiakResult ) result ;
238252 }
239253
240- return onError ( ResultCode . ClusterOffline , "Unable to access functioning Riak node" , true ) ;
254+ return onError ( ResultCode . ClusterOffline , "Unable to access functioning Riak node (load balancer returned no nodes). " , true ) ;
241255 }
242256
243257 private void MaybeDeactivateNode ( bool nodeOffline , IRiakNode node )
0 commit comments