Commit be1700af authored by Nick Craver's avatar Nick Craver

Fix exception logging to prefer the RedisException type.

This sets a proper RedisException on the Message, but has the core exception as InnerException as you'd expect.

This also means the Message will have the info we add to it, rather than *sometimes* having it.
parent 92407cf1
...@@ -272,6 +272,7 @@ public Task FlushAsync() ...@@ -272,6 +272,7 @@ public Task FlushAsync()
public void RecordConnectionFailed(ConnectionFailureType failureType, Exception innerException = null, [CallerMemberName] string origin = null) public void RecordConnectionFailed(ConnectionFailureType failureType, Exception innerException = null, [CallerMemberName] string origin = null)
{ {
Exception outerException = innerException;
IdentifyFailureType(innerException, ref failureType); IdentifyFailureType(innerException, ref failureType);
if (failureType == ConnectionFailureType.InternalFailure) OnInternalError(innerException, origin); if (failureType == ConnectionFailureType.InternalFailure) OnInternalError(innerException, origin);
...@@ -330,16 +331,16 @@ void add(string lk, string sk, string v) ...@@ -330,16 +331,16 @@ void add(string lk, string sk, string v)
add("Last-Global-Heartbeat", "global", ConnectionMultiplexer.LastGlobalHeartbeatSecondsAgo + "s ago"); add("Last-Global-Heartbeat", "global", ConnectionMultiplexer.LastGlobalHeartbeatSecondsAgo + "s ago");
} }
var ex = innerException == null outerException = innerException == null
? new RedisConnectionException(failureType, exMessage.ToString()) ? new RedisConnectionException(failureType, exMessage.ToString())
: new RedisConnectionException(failureType, exMessage.ToString(), innerException); : new RedisConnectionException(failureType, exMessage.ToString(), innerException);
foreach (var kv in data) foreach (var kv in data)
{ {
ex.Data["Redis-" + kv.Item1] = kv.Item2; outerException.Data["Redis-" + kv.Item1] = kv.Item2;
} }
Bridge.OnConnectionFailed(this, failureType, ex); Bridge.OnConnectionFailed(this, failureType, outerException);
} }
// cleanup // cleanup
...@@ -350,7 +351,7 @@ void add(string lk, string sk, string v) ...@@ -350,7 +351,7 @@ void add(string lk, string sk, string v)
{ {
var next = _writtenAwaitingResponse.Dequeue(); var next = _writtenAwaitingResponse.Dequeue();
Bridge.Trace("Failing: " + next); Bridge.Trace("Failing: " + next);
next.SetException(innerException); next.SetException(innerException is RedisException ? innerException : outerException);
Bridge.CompleteSyncOrAsync(next); Bridge.CompleteSyncOrAsync(next);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment