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 missing top-level exception handling for arg validation #5111

Merged
merged 1 commit into from
Jan 7, 2025

Conversation

florelis
Copy link
Member

@florelis florelis commented Jan 6, 2025

The CLI arg validation code has gotten more complicated and now there is more room for exceptions to occur. For example, if there is an error when reading the admin settings or group policies that determine if an argument is available.

This adds generic exception handling at the top-level of arg validation so that we can exit gracefully and show an error, instead of just crashing.

Partial fix for #5098. This addresses the no output, but not the cause of the error

Microsoft Reviewers: Open in CodeFlow

@florelis florelis requested a review from a team as a code owner January 6, 2025 23:03
}
catch (...)
{
return Workflow::HandleException(context, std::current_exception());
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Workflow::HandleException handles GroupPolicyException above. Btw I don't have preference on whether we would list GroupPolicyException above explicitly or let HandleException handle all non-command exceptions.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm in favor of having explicit handling in this case, since the message for Group Policy is quite clear about what is happening

@florelis florelis merged commit dfc5a8f into microsoft:master Jan 7, 2025
9 checks passed
@florelis florelis deleted the catch branch January 7, 2025 01:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants