Commit c4412192 authored by dverma's avatar dverma Committed by Nick Craver

AbortOnConnectFailure message in unabletoconnect exception if AbortOnConnectFailure is set (#571)

parent 5b638256
......@@ -794,7 +794,7 @@ public static async Task<ConnectionMultiplexer> ConnectAsync(string configuratio
bool configured = await muxer.ReconfigureAsync(true, false, log, null, "connect").ObserveErrors().ForAwait();
if (!configured)
{
throw ExceptionFactory.UnableToConnect(muxer.failureMessage);
throw ExceptionFactory.UnableToConnect(muxer.RawConfig.AbortOnConnectFail, muxer.failureMessage);
}
killMe = null;
return muxer;
......@@ -817,7 +817,7 @@ public static async Task<ConnectionMultiplexer> ConnectAsync(ConfigurationOption
bool configured = await muxer.ReconfigureAsync(true, false, log, null, "connect").ObserveErrors().ForAwait();
if (!configured)
{
throw ExceptionFactory.UnableToConnect(muxer.failureMessage);
throw ExceptionFactory.UnableToConnect(muxer.RawConfig.AbortOnConnectFail, muxer.failureMessage);
}
killMe = null;
return muxer;
......@@ -876,14 +876,14 @@ private static ConnectionMultiplexer ConnectImpl(Func<ConnectionMultiplexer> mul
task.ObserveErrors();
if (muxer.RawConfig.AbortOnConnectFail)
{
throw ExceptionFactory.UnableToConnect("ConnectTimeout");
throw ExceptionFactory.UnableToConnect(muxer.RawConfig.AbortOnConnectFail, "ConnectTimeout");
}
else
{
muxer.LastException = ExceptionFactory.UnableToConnect("ConnectTimeout");
muxer.LastException = ExceptionFactory.UnableToConnect(muxer.RawConfig.AbortOnConnectFail, "ConnectTimeout");
}
}
if (!task.Result) throw ExceptionFactory.UnableToConnect(muxer.failureMessage);
if (!task.Result) throw ExceptionFactory.UnableToConnect(muxer.RawConfig.AbortOnConnectFail, muxer.failureMessage);
killMe = null;
return muxer;
}
......
......@@ -194,10 +194,11 @@ static string GetLabel(bool includeDetail, RedisCommand command, Message message
return message == null ? command.ToString() : (includeDetail ? message.CommandAndKey : message.Command.ToString());
}
internal static Exception UnableToConnect(string failureMessage=null)
internal static Exception UnableToConnect(bool abortOnConnect, string failureMessage=null)
{
var abortOnConnectionFailure = abortOnConnect ? "to create a disconnected multiplexer, disable AbortOnConnectFail. " : "";
return new RedisConnectionException(ConnectionFailureType.UnableToConnect,
"It was not possible to connect to the redis server(s); to create a disconnected multiplexer, disable AbortOnConnectFail. " + failureMessage);
string.Format("It was not possible to connect to the redis server(s); {0}{1}", abortOnConnectionFailure, failureMessage));
}
internal static Exception BeganProfilingWithDuplicateContext(object forContext)
......
......@@ -388,7 +388,7 @@ internal void OnHeartbeat(bool ifConnectedOnly)
if (shouldRetry)
{
Interlocked.Increment(ref connectTimeoutRetryCount);
LastException = ExceptionFactory.UnableToConnect("ConnectTimeout");
LastException = ExceptionFactory.UnableToConnect(Multiplexer.RawConfig.AbortOnConnectFail, "ConnectTimeout");
Trace("Aborting connect");
// abort and reconnect
var snapshot = physical;
......
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