String ConfigObjectUtility::GetConfigDir()
{
+ /* This may throw an exception the caller above must handle. */
return ConfigPackageUtility::GetPackageDir() + "/_api/" +
ConfigPackageUtility::GetActiveStage("_api");
}
String typeDir = type->GetPluralName();
boost::algorithm::to_lower(typeDir);
- return GetConfigDir() + "/conf.d/" + typeDir +
+ /* This may throw an exception the caller above must handle. */
+ String prefix = GetConfigDir();
+
+ return prefix + "/conf.d/" + typeDir +
"/" + EscapeName(fullName) + ".conf";
}
return false;
}
- String path = GetObjectConfigPath(type, fullName);
+ String path;
+
+ try {
+ path = GetObjectConfigPath(type, fullName);
+ } catch (const std::exception& ex) {
+ errors->Add("Config package broken: " + DiagnosticInformation(ex, false));
+ return false;
+ }
+
Utility::MkDirP(Utility::DirName(path), 0700);
std::ofstream fp(path.CStr(), std::ofstream::out | std::ostream::trunc);
return false;
}
- String path = GetObjectConfigPath(object->GetReflectionType(), name);
+ String path;
+
+ try {
+ path = GetObjectConfigPath(object->GetReflectionType(), name);
+ } catch (const std::exception& ex) {
+ errors->Add("Config package broken: " + DiagnosticInformation(ex, false));
+ return false;
+ }
Utility::Remove(path);
boost::mutex::scoped_lock lock(ConfigPackageUtility::GetStaticPackageMutex());
for (const String& package : packages) {
+ String activeStage;
+
+ try {
+ activeStage = ConfigPackageUtility::GetActiveStage(package);
+ } catch (const std::exception&) { } /* Should never happen. */
+
results.emplace_back(new Dictionary({
{ "name", package },
{ "stages", Array::FromVector(ConfigPackageUtility::GetStages(package)) },
- { "active-stage", ConfigPackageUtility::GetActiveStage(package) }
+ { "active-stage", activeStage }
}));
}
}