(#3258) Expand logging for nuget resources errors #3262
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description Of Changes
The reason the outermost and innermost exceptions are logged as warnings and the rest are relegated to debug is so that we have the best chance of giving users the most actionable information -- often the surface or the deepest exception contain the real problem, while the ones in the middle are often not as useful. However, should we encounter cases where the others are needed, users can inspect the log file for the additional messages, or use
--debug
to see them on a re-run.Motivation and Context
Previously all that was logged was the surface exception, which in quite a few cases we've seen not yielding any useful information.
Instead, log the entire exception chain, surfacing just the outermost and innermost exceptions, which we generally expect to contain the most relevant information for users.
Testing
Reproducing the exact cases we've seen this thus far seemed non-trivial and needing quite a bit of setup to me, so I found this trivial case that illustrates the same behaviour:
choco search chocolatey --source https://www.google.com/ --proxy www.google.com
unable to load the service index
, and another that saysthe remote server returned an error (405)
--debug
and note there is an additional (in this case, not useful) exception logged between the two warnings that simply saysan error occurred while sending the request
Operating Systems Testing
Win11
Change Types Made
Change Checklist
Related Issue
Fixes #3258