Commit ef37548a authored by DeepakVerma's avatar DeepakVerma

SE.Redis better error in the exception message by including innerexception details

parent 0b47916a
...@@ -74,10 +74,26 @@ internal static Exception MultiSlot(bool includeDetail, Message message) ...@@ -74,10 +74,26 @@ internal static Exception MultiSlot(bool includeDetail, Message message)
if (includeDetail) AddDetail(ex, message, null, null); if (includeDetail) AddDetail(ex, message, null, null);
return ex; return ex;
} }
internal static string GetInnerMostExceptionMessage(Exception e)
{
if (e == null)
{
return "";
}
else
{
while (e.InnerException != null)
{
e = e.InnerException;
}
return e.Message;
}
}
internal static Exception NoConnectionAvailable(bool includeDetail, RedisCommand command, Message message, ServerEndPoint server, ServerEndPoint[] serverSnapshot) internal static Exception NoConnectionAvailable(bool includeDetail, RedisCommand command, Message message, ServerEndPoint server, ServerEndPoint[] serverSnapshot)
{ {
string s = GetLabel(includeDetail, command, message); string commandLabel = GetLabel(includeDetail, command, message);
if (server != null) if (server != null)
{ {
...@@ -85,11 +101,19 @@ internal static Exception NoConnectionAvailable(bool includeDetail, RedisCommand ...@@ -85,11 +101,19 @@ internal static Exception NoConnectionAvailable(bool includeDetail, RedisCommand
//otherwise it would output state of all the endpoints //otherwise it would output state of all the endpoints
serverSnapshot = new ServerEndPoint[] { server }; serverSnapshot = new ServerEndPoint[] { server };
} }
string exceptionmessage = "No connection is available to service this operation: " + s ;
var ex = new RedisConnectionException(ConnectionFailureType.UnableToResolvePhysicalConnection, exceptionmessage, GetServerSnapshotInnerExceptions(serverSnapshot)); var innerException = GetServerSnapshotInnerExceptions(serverSnapshot);
StringBuilder exceptionmessage = new StringBuilder("No connection is available to service this operation: ");
exceptionmessage.Append(commandLabel);
exceptionmessage.Append("; ");
exceptionmessage.Append(GetInnerMostExceptionMessage(innerException));
var ex = new RedisConnectionException(ConnectionFailureType.UnableToResolvePhysicalConnection, exceptionmessage.ToString(), innerException);
if (includeDetail) if (includeDetail)
{ {
AddDetail(ex, message, server, s); AddDetail(ex, message, server, commandLabel);
} }
return ex; return ex;
} }
......
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