winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit dfc5a8f30ac38635d5f7fb76e614af18d471176f
parent b49f784e4b1d5bf2b8aa85dfbe3ba5d360b6be12
Author: Flor Chacón <14323496+florelis@users.noreply.github.com>
Date:   Mon,  6 Jan 2025 16:54:56 -0800

Add missing top-level exception handling for arg validation (#5111)

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](https://microsoft.github.io/open-pr/?codeflow=https://github.com/microsoft/winget-cli/pull/5111)
Diffstat:
Msrc/AppInstallerCLICore/Core.cpp | 4++++
1 file changed, 4 insertions(+), 0 deletions(-)

diff --git a/src/AppInstallerCLICore/Core.cpp b/src/AppInstallerCLICore/Core.cpp @@ -172,6 +172,10 @@ namespace AppInstaller::CLI AICLI_LOG(CLI, Error, << "Operation blocked by Group Policy: " << policy.RegValueName()); context.Reporter.Error() << Resource::String::DisabledByGroupPolicy(policy.PolicyName()) << std::endl; return APPINSTALLER_CLI_ERROR_BLOCKED_BY_POLICY; + } + catch (...) + { + return Workflow::HandleException(context, std::current_exception()); } return Execute(context, command);