mirror of
https://review.haiku-os.org/haiku
synced 2025-01-31 02:35:03 +01:00
HaikuDepot: Wrap dependency resolution in try/catch block.
- Ensure that any exceptions thrown by the package kit are caught and handled.
This commit is contained in:
parent
a27d687e2a
commit
a24b8b8055
@ -528,20 +528,19 @@ MainWindow::_RefreshPackageList()
|
||||
}
|
||||
|
||||
// compute the OS package dependencies
|
||||
try {
|
||||
// create the solver
|
||||
BSolver* solver;
|
||||
status_t error = BSolver::Create(solver);
|
||||
if (error != B_OK) {
|
||||
printf("failed to create solver: %s\n", strerror(error));
|
||||
return;
|
||||
}
|
||||
if (error != B_OK)
|
||||
throw BFatalErrorException(error, "Failed to create solver.");
|
||||
|
||||
ObjectDeleter<BSolver> solverDeleter(solver);
|
||||
BPath systemPath;
|
||||
error = find_directory(B_SYSTEM_PACKAGES_DIRECTORY, &systemPath);
|
||||
if (error != B_OK) {
|
||||
printf("Unable to retrieve system packages directory: %s\n", strerror(error));
|
||||
return;
|
||||
throw BFatalErrorException(error, "Unable to retrieve system "
|
||||
"packages directory.");
|
||||
}
|
||||
|
||||
// add the "installed" repository with the given packages
|
||||
@ -574,26 +573,39 @@ MainWindow::_RefreshPackageList()
|
||||
// solve
|
||||
error = solver->VerifyInstallation();
|
||||
if (error != B_OK) {
|
||||
printf("failed to compute packages to install: %s\n", strerror(error));
|
||||
return;
|
||||
throw BFatalErrorException(error, "Failed to compute packages to "
|
||||
"install.");
|
||||
}
|
||||
|
||||
BSolverResult solverResult;
|
||||
error = solver->GetResult(solverResult);
|
||||
if (error != B_OK) {
|
||||
printf("failed to get packages to install: %s\n", strerror(error));
|
||||
return;
|
||||
throw BFatalErrorException(error, "Failed to retrieve system "
|
||||
"package dependency list.");
|
||||
}
|
||||
|
||||
for (int32 i = 0; const BSolverResultElement* element
|
||||
= solverResult.ElementAt(i); i++) {
|
||||
BSolverPackage* package = element->Package();
|
||||
if (element->Type() == BSolverResultElement::B_TYPE_INSTALL) {
|
||||
PackageInfoMap::iterator it = systemInstalledPackages.find(package->Info().FileName());
|
||||
PackageInfoMap::iterator it = systemInstalledPackages.find(
|
||||
package->Info().FileName());
|
||||
if (it != systemInstalledPackages.end())
|
||||
it->second->SetSystemDependency(true);
|
||||
}
|
||||
}
|
||||
} catch (BFatalErrorException ex) {
|
||||
printf("Fatal exception occurred while resolving system dependencies: "
|
||||
"%s, details: %s\n", strerror(ex.Error()), ex.Details().String());
|
||||
} catch (BNothingToDoException) {
|
||||
// do nothing
|
||||
} catch (BException ex) {
|
||||
printf("Exception occurred while resolving system dependencies: %s\n",
|
||||
ex.Message().String());
|
||||
} catch (...) {
|
||||
printf("Unknown exception occurred while resolving system "
|
||||
"dependencies.\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user