Skip to content

Commit c84f06c

Browse files
authored
Swallow provisioned package errors (microsoft#5595)
## Change Catch errors coming from `FindProvisionedPackages` and ignore them. This is most likely to happen when the caller is not elevated.
1 parent c61fde9 commit c84f06c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/AppInstallerRepositoryCore/Microsoft/PredefinedInstalledSourceFactory.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,15 @@ namespace AppInstaller::Repository::Microsoft
7575
IPackageManager9 packageManager9 = packageManager.try_as<IPackageManager9>();
7676
if (packageManager9)
7777
{
78-
packages = packageManager.FindProvisionedPackages();
78+
try
79+
{
80+
packages = packageManager.FindProvisionedPackages();
81+
}
82+
catch (const winrt::hresult_error& hre)
83+
{
84+
// Historically this API has not been accessible unelevated; if it fails, try to carry on
85+
AICLI_LOG(Repo, Warning, << "FindProvisionedPackages failed, bypassing provisioned packages: 0x" << Logging::SetHRFormat << hre.code());
86+
}
7987
}
8088
else
8189
{

0 commit comments

Comments
 (0)