#1001 don't log stack traces for localhost bind failures.

This commit is contained in:
Chris R 2016-11-28 15:24:30 -08:00
parent 02b84d7ae1
commit 53e5c3d56c
1 changed files with 8 additions and 6 deletions

View File

@ -150,14 +150,15 @@ namespace Microsoft.AspNetCore.Server.Kestrel
} }
catch (AggregateException ex) when (ex.InnerException is UvException) catch (AggregateException ex) when (ex.InnerException is UvException)
{ {
if ((ex.InnerException as UvException).StatusCode == Constants.EADDRINUSE) var uvEx = (UvException)ex.InnerException;
if (uvEx.StatusCode == Constants.EADDRINUSE)
{ {
throw new IOException($"Failed to bind to address {parsedAddress.ToString()} on the IPv4 loopback interface: port already in use.", ex); throw new IOException($"Failed to bind to address {parsedAddress.ToString()} on the IPv4 loopback interface: port already in use.", ex);
} }
else else
{ {
_logger.LogWarning(0, ex, $"Unable to bind to {parsedAddress.ToString()} on the IPv4 loopback interface."); _logger.LogWarning(0, $"Unable to bind to {parsedAddress.ToString()} on the IPv4 loopback interface: ({uvEx.Message})");
exceptions.Add(ex.InnerException); exceptions.Add(uvEx);
} }
} }
@ -169,14 +170,15 @@ namespace Microsoft.AspNetCore.Server.Kestrel
} }
catch (AggregateException ex) when (ex.InnerException is UvException) catch (AggregateException ex) when (ex.InnerException is UvException)
{ {
if ((ex.InnerException as UvException).StatusCode == Constants.EADDRINUSE) var uvEx = (UvException)ex.InnerException;
if (uvEx.StatusCode == Constants.EADDRINUSE)
{ {
throw new IOException($"Failed to bind to address {parsedAddress.ToString()} on the IPv6 loopback interface: port already in use.", ex); throw new IOException($"Failed to bind to address {parsedAddress.ToString()} on the IPv6 loopback interface: port already in use.", ex);
} }
else else
{ {
_logger.LogWarning(0, ex, $"Unable to bind to {parsedAddress.ToString()} on the IPv6 loopback interface."); _logger.LogWarning(0, $"Unable to bind to {parsedAddress.ToString()} on the IPv6 loopback interface: ({uvEx.Message})");
exceptions.Add(ex.InnerException); exceptions.Add(uvEx);
} }
} }