diff --git a/src/chocolatey/ExceptionExtensions.cs b/src/chocolatey/ExceptionExtensions.cs new file mode 100644 index 0000000000..eda7e450a9 --- /dev/null +++ b/src/chocolatey/ExceptionExtensions.cs @@ -0,0 +1,21 @@ +namespace chocolatey +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Text; + using System.Threading.Tasks; + + public static class ExceptionExtensions + { + public static IEnumerable Enumerate(this Exception error) + { + while (error != null) + { + yield return error; + + error = error.InnerException; + } + } + } +} diff --git a/src/chocolatey/chocolatey.csproj b/src/chocolatey/chocolatey.csproj index eb291d883c..7c2f36db0b 100644 --- a/src/chocolatey/chocolatey.csproj +++ b/src/chocolatey/chocolatey.csproj @@ -1,4 +1,4 @@ - + @@ -200,6 +200,7 @@ Properties\SolutionVersion.cs + @@ -538,4 +539,4 @@ --> - \ No newline at end of file + diff --git a/src/chocolatey/infrastructure.app/nuget/NuGetEndpointResources.cs b/src/chocolatey/infrastructure.app/nuget/NuGetEndpointResources.cs index e93e9b0be8..9189b69251 100644 --- a/src/chocolatey/infrastructure.app/nuget/NuGetEndpointResources.cs +++ b/src/chocolatey/infrastructure.app/nuget/NuGetEndpointResources.cs @@ -153,7 +153,32 @@ private T ResolveResource() { if (!_resolvingFailed) { - this.Log().Warn(ex.InnerException.Message); + // Unwrap the AggregateException as its surface message is useless + Exception error = ex.InnerException; + this.Log().Warn(error.Message); + + // Enumerate the inner exceptions, log all but the last one in the list to debug + string message = null; + foreach (var err in error.InnerException.Enumerate()) + { + if (message != null) + { + this.Log().Debug(message); + } + + message = err.Message; + error = err; + } + + // If the last error in the list isn't the only one, write its message as a warning. + // Typically the deepest/last error in the InnerExceptions will be a relevant and + // actionable error. + if (error != ex.InnerException && message != null) + { + this.Log().Warn(message); + } + + this.Log().Warn("For more information on this issue and guidance in resolving the problem, see https://ch0.co/t/svcidx"); _resolvingFailed = true; } }