-
Notifications
You must be signed in to change notification settings - Fork 688
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make RestoreCommand handle unexpected exceptions. #5997
base: dev
Are you sure you want to change the base?
Conversation
Comment from closed PR: #5878 (review)
|
Currently, the idea is to catch all exceptions in Regarding the error code, I agree that we should have a general error code for this scenario. However, if the exception thrown has an error code with it, we should use the exceptions error code. |
That makes sense to me.
One thing that might be tricky is that in the current implementation when we catch FatalProtocolException we don't really log the message, we assume it's already been logged. |
Erro code:
Double logging
|
|
||
if (unwrappedLogMessage != null) | ||
{ | ||
assetsFile.LogMessages.Add(new AssetsLogMessage(LogLevel.Error, unwrappedLogMessage.Code, unwrappedLogMessage.Message, null)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your CLI restore example shows that MSBuild is attributing the exception to NuGet.targets, and not the csproj file. There's a property on AssetsLogMessage
so NuGet tells MSBuild which project file the error is related to, which should be filled in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just updated the CLI example in the description section. The screenshot I had was an old one - before I started adding the error to an assets file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about building the assets file after you log the message to the logger.
Currently this adds another place where we can create a discrepancy.
The pattern currently is:
- You log warnings to the "collector" logger.
- When you create the assets file, the "collector" logger creates assets file warnings.
- It'd also be ideal if the failed restore result is created into fewer places. Same reason as above, fewer chances of a discrepancy.
Can we please add a test for this change that documents the desired behavior? |
Bug
Fixes: NuGet/Home#13188
Description
recreates #5878
For the screenshots below, the following synthetic projects were used:
- bad.csproj : A project that throws an exception upon restore.
- good.csproj: A project that restores successfully.
- multiprojectWithOneErrors.csproj: A project
Currently, restoring this solution will result in an exception that interrupts the restore from restoring projects that did not cause the exception.
After this change, exception are caught allowing restore to complete for other projects as following:
VS side
After the change, here's how the errors will be displayed on VS:
PR Checklist