{
FilterUtility::CheckPermission(user, "config/query");
- std::vector<String> packages = ConfigPackageUtility::GetPackages();
+ std::vector<String> packages;
+
+ try {
+ packages = ConfigPackageUtility::GetPackages();
+ } catch (const std::exception& ex) {
+ HttpUtility::SendJsonError(response, 500, "Could not retrieve packages.");
+ return;
+ }
Array::Ptr results = new Array();
boost::mutex::scoped_lock lock(ConfigPackageUtility::GetStaticMutex());
ConfigPackageUtility::CreatePackage(packageName);
} catch (const std::exception& ex) {
- HttpUtility::SendJsonError(response, 500, "Could not create package.",
- HttpUtility::GetLastParameter(params, "verboseErrors") ? DiagnosticInformation(ex) : "");
+ HttpUtility::SendJsonError(response, 500, "Could not create package.", "");
}
result1->Set("code", 200);
std::vector<String> ConfigPackageUtility::GetPackages(void)
{
+ String packageDir = GetPackageDir();
+
std::vector<String> packages;
- Utility::Glob(GetPackageDir() + "/*", boost::bind(&ConfigPackageUtility::CollectDirNames,
- _1, boost::ref(packages)), GlobDirectory);
+
+ /* Package directory does not exist, no packages have been created thus far. */
+ if (!Utility::PathExists(packageDir))
+ return packages;
+
+ Utility::Glob(packageDir + "/*", boost::bind(&ConfigPackageUtility::CollectDirNames,
+ _1, std::ref(packages)), GlobDirectory);
+
return packages;
}