Commit 9426e1af authored by Marc Gravell's avatar Marc Gravell

add the SocketConnection ShutdownKind/SocketError to the failure outputl make...

add the SocketConnection ShutdownKind/SocketError to the failure outputl make Roslynator happy in a bunch of places
parent a52077c2
......@@ -125,7 +125,7 @@ internal static Exception NoConnectionAvailable(bool includeDetail, bool include
internal static Exception PopulateInnerExceptions(ReadOnlySpan<ServerEndPoint> serverSnapshot)
{
var innerExceptions = new List<Exception>();
if (serverSnapshot.Length > 0 && serverSnapshot[0].Multiplexer.LastException != null)
{
innerExceptions.Add(serverSnapshot[0].Multiplexer.LastException);
......@@ -195,10 +195,6 @@ private static string GetLabel(bool includeDetail, RedisCommand command, Message
return message == null ? command.ToString() : (includeDetail ? message.CommandAndKey : message.Command.ToString());
}
private static string GetLabel(bool includeDetail, string command, Message message)
{
return message == null ? command : (includeDetail ? message.CommandAndKey : message.Command.ToString());
}
internal static Exception UnableToConnect(ConnectionMultiplexer muxer, string failureMessage=null)
{
var sb = new StringBuilder("It was not possible to connect to the redis server(s).");
......
......@@ -275,7 +275,8 @@ public Task FlushAsync()
return Task.CompletedTask;
}
public void RecordConnectionFailed(ConnectionFailureType failureType, Exception innerException = null, [CallerMemberName] string origin = null, bool isInitialConnect = false)
public void RecordConnectionFailed(ConnectionFailureType failureType, Exception innerException = null, [CallerMemberName] string origin = null,
bool isInitialConnect = false, IDuplexPipe connectingPipe = null)
{
Exception outerException = innerException;
IdentifyFailureType(innerException, ref failureType);
......@@ -307,6 +308,16 @@ public void RecordConnectionFailed(ConnectionFailureType failureType, Exception
var exMessage = new StringBuilder(failureType.ToString());
if ((connectingPipe ?? _ioPipe) is SocketConnection sc)
{
exMessage.Append(" (").Append(sc.ShutdownKind);
if (sc.SocketError != SocketError.Success)
{
exMessage.Append("/").Append(sc.SocketError);
}
exMessage.Append(")");
}
var data = new List<Tuple<string, string>>();
if (IncludeDetailInExceptions)
{
......@@ -1082,6 +1093,7 @@ internal async ValueTask<bool> ConnectedAsync(Socket socket, TextWriter log, Soc
var bridge = BridgeCouldBeNull;
if (bridge == null) return false;
IDuplexPipe pipe = null;
try
{
// disallow connection in some cases
......@@ -1093,7 +1105,6 @@ internal async ValueTask<bool> ConnectedAsync(Socket socket, TextWriter log, Soc
var config = bridge.Multiplexer.RawConfig;
IDuplexPipe pipe;
if (config.Ssl)
{
bridge.Multiplexer.LogLocked(log, "Configuring SSL");
......@@ -1141,7 +1152,7 @@ internal async ValueTask<bool> ConnectedAsync(Socket socket, TextWriter log, Soc
}
catch (Exception ex)
{
RecordConnectionFailed(ConnectionFailureType.InternalFailure, ex, isInitialConnect: true); // includes a bridge.OnDisconnected
RecordConnectionFailed(ConnectionFailureType.InternalFailure, ex, isInitialConnect: true, connectingPipe: pipe); // includes a bridge.OnDisconnected
bridge.Multiplexer.Trace("Could not connect: " + ex.Message, physicalName);
return false;
}
......
......@@ -1737,7 +1737,7 @@ protected NameValueEntry[] ParseStreamEntryValues(RawResult result)
}
var arr = result.GetItems();
// Calculate how many name/value pairs are in the stream entry.
int count = arr.Length / 2;
......
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