Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit c77219f

Browse files
committed
Add original Error message + timestamps to Redis retry exceptions
1 parent 78b7788 commit c77219f

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

src/ServiceStack.Redis/RedisNativeClient_Utils.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -315,19 +315,21 @@ private RedisRetryableException CreateRetryableResponseError(string error)
315315
{
316316
string safeLastCommand = string.IsNullOrEmpty(Password) ? lastCommand : (lastCommand ?? "").Replace(Password, "");
317317

318-
var throwEx = new RedisRetryableException(
319-
string.Format("{0}, sPort: {1}, LastCommand: {2}",
318+
var throwEx = new RedisRetryableException(string.Format("[{0}] {1}, sPort: {2}, LastCommand: {3}",
319+
DateTime.UtcNow.ToString("HH:mm:ss.fff"),
320320
error, clientPort, safeLastCommand));
321321
log.Error(throwEx.Message);
322322
throw throwEx;
323323
}
324324

325-
private RedisException CreateConnectionError()
325+
private RedisException CreateConnectionError(Exception originalEx)
326326
{
327327
DeactivatedAt = DateTime.UtcNow;
328-
var throwEx = new RedisException(
329-
string.Format("Unable to Connect: sPort: {0}",
330-
clientPort), lastSocketException);
328+
var throwEx = new RedisException(string.Format("[{0}] Unable to Connect: sPort: {1}{2}",
329+
DateTime.UtcNow.ToString("HH:mm:ss.fff"),
330+
clientPort,
331+
originalEx != null ? ", Error: " + originalEx.Message : ""),
332+
lastSocketException);
331333
log.Error(throwEx.Message);
332334
throw throwEx;
333335
}
@@ -559,7 +561,7 @@ protected T SendReceive<T>(byte[][] cmdWithBinaryArgs,
559561

560562
var ex = retryableEx ?? GetRetryableException(outerEx);
561563
if (ex == null)
562-
throw CreateConnectionError();
564+
throw CreateConnectionError(originalEx ?? outerEx);
563565

564566
if (originalEx == null)
565567
originalEx = ex;

0 commit comments

Comments
 (0)