Skip to content
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

Add Installer Exceptions for handling matching exceptions from core library #138

Merged
merged 7 commits into from
Aug 23, 2021

Conversation

ryfu-msft
Copy link
Contributor

@ryfu-msft ryfu-msft commented Aug 17, 2021

Resolves #101

Instead of adding localization to the core library as a means for conveying an error to the calling function, I believe our issues can be fixed by throwing custom exceptions and catching those thrown exceptions in the calling function. As of right now, there hasn't been a need to add any logging functionality to the core library as all of the logging takes place in the CLI and we should try to maintain that design choice until we absolutely need to make that change.

Changes:

  • Added custom InstallerExceptions for MultipleMatchedInstallerException and UnmatchedInstallerException which both take in an Installer parameter to better pass information about the installer causing the matching error.
  • Handle these unique exceptions in the calling function in UpdateCommand.
Microsoft Reviewers: Open in CodeFlow

@ryfu-msft ryfu-msft requested a review from a team as a code owner August 17, 2021 19:13
@ghost ghost added the Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. label Aug 17, 2021
{
Logger.ErrorLocalized(nameof(Resources.NewInstallerUrlMustMatchExisting_Message));
DisplayMismatchedArchitectures(detectedArchOfInstallers);
Logger.ErrorLocalized(nameof(Resources.PackageParsing_Error));
Copy link

@jamespik jamespik Aug 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still looks like some errrors are return via exceptions, and others via exit code. Why do we have split error handling? #Resolved

Copy link
Contributor Author

@ryfu-msft ryfu-msft Aug 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe in this case, all our errors should be handled with exceptions. That way we can obtain better information about the specific packages that failed parsing. I modified the method so that there's no split error handling

@@ -288,6 +288,12 @@ protected static async Task<string> DownloadPackageFile(string installerUrl)
return null;
}

if (e is InvalidDataException)
{
Logger.ErrorLocalized(nameof(Resources.DownloadFileExceedsMaxSize_Error), e.Message);
Copy link

@jamespik jamespik Aug 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of just putting this in the message i rather like making these strange typed values on the exception, like what you did for the other exception. In that manner, we can still jhave a meaningful message on the exception for debugging, but the data the caller needs to derive a good localized error message can still be handed out? #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created a new exception for DownloadSizeExceeded similar to the other exceptions I created so that the data value isn't hidden in the exception message.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lol.. "Strong" not strange :)

Copy link
Contributor

@palenshus palenshus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🕐

@ghost ghost removed the Needs-Author-Feedback label Aug 20, 2021
src/WingetCreateCLI/Commands/BaseCommand.cs Outdated Show resolved Hide resolved
src/WingetCreateCLI/Commands/UpdateCommand.cs Outdated Show resolved Hide resolved
Copy link
Contributor

@palenshus palenshus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@ghost ghost removed the Needs-Author-Feedback label Aug 23, 2021
@ryfu-msft ryfu-msft merged commit 7d4b6a4 into main Aug 23, 2021
@ryfu-msft ryfu-msft deleted the localizeLibrary branch August 23, 2021 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add localization to WingetCreateCore to provide better error messages from library functions
3 participants