mirror of https://github.com/Icinga/icinga2.git
parent
abe583f7d9
commit
764d72a61a
|
@ -62,14 +62,28 @@ static String LoadAppType(const String& typeSpec)
|
|||
return typeSpec.SubStr(index + 1);
|
||||
}
|
||||
|
||||
static void ExecuteExpression(Expression *expression)
|
||||
{
|
||||
Dictionary::Ptr context = new Dictionary();
|
||||
|
||||
try {
|
||||
expression->Evaluate(context);
|
||||
} catch (const ConfigError& ex) {
|
||||
const DebugInfo *di = boost::get_error_info<errinfo_debuginfo>(ex);
|
||||
ConfigCompilerContext::GetInstance()->AddMessage(true, ex.what(), di ? *di : DebugInfo());
|
||||
} catch (const std::exception& ex) {
|
||||
ConfigCompilerContext::GetInstance()->AddMessage(true, DiagnosticInformation(ex));
|
||||
}
|
||||
}
|
||||
|
||||
static void IncludeZoneDirRecursive(const String& path)
|
||||
{
|
||||
String zoneName = Utility::BaseName(path);
|
||||
|
||||
std::vector<Expression *> expressions;
|
||||
Utility::GlobRecursive(path, "*.conf", boost::bind(&ConfigCompiler::CollectIncludes, boost::ref(expressions), _1, zoneName), GlobFile);
|
||||
Dictionary::Ptr context = new Dictionary();
|
||||
DictExpression(expressions).Evaluate(context);
|
||||
DictExpression expr(expressions);
|
||||
ExecuteExpression(&expr);
|
||||
}
|
||||
|
||||
static void IncludeNonLocalZone(const String& zonePath)
|
||||
|
@ -93,13 +107,13 @@ static bool LoadConfigFiles(const boost::program_options::variables_map& vm, con
|
|||
if (vm.count("config") > 0) {
|
||||
BOOST_FOREACH(const String& configPath, vm["config"].as<std::vector<std::string> >()) {
|
||||
Expression *expression = ConfigCompiler::CompileFile(configPath);
|
||||
Dictionary::Ptr context = new Dictionary();
|
||||
expression->Evaluate(context);
|
||||
ExecuteExpression(expression);
|
||||
delete expression;
|
||||
}
|
||||
} else if (!vm.count("no-config")) {
|
||||
Expression *expression = ConfigCompiler::CompileFile(Application::GetSysconfDir() + "/icinga2/icinga2.conf");
|
||||
Dictionary::Ptr context = new Dictionary();
|
||||
expression->Evaluate(context);
|
||||
ExecuteExpression(expression);
|
||||
delete expression;
|
||||
}
|
||||
|
||||
/* Load cluster config files - this should probably be in libremote but
|
||||
|
@ -115,8 +129,8 @@ static bool LoadConfigFiles(const boost::program_options::variables_map& vm, con
|
|||
String name, fragment;
|
||||
BOOST_FOREACH(boost::tie(name, fragment), ConfigFragmentRegistry::GetInstance()->GetItems()) {
|
||||
Expression *expression = ConfigCompiler::CompileText(name, fragment);
|
||||
Dictionary::Ptr context = new Dictionary();
|
||||
expression->Evaluate(context);
|
||||
ExecuteExpression(expression);
|
||||
delete expression;
|
||||
}
|
||||
|
||||
ConfigItemBuilder::Ptr builder = new ConfigItemBuilder();
|
||||
|
|
|
@ -46,7 +46,7 @@ Value Expression::Evaluate(const Object::Ptr& context, DebugHint *dhint) const
|
|||
|
||||
return DoEvaluate(context, dhint);
|
||||
} catch (const std::exception& ex) {
|
||||
if (boost::get_error_info<boost::errinfo_nested_exception>(ex))
|
||||
if (dynamic_cast<const ConfigError *>(&ex) || boost::get_error_info<boost::errinfo_nested_exception>(ex))
|
||||
throw;
|
||||
else
|
||||
BOOST_THROW_EXCEPTION(ConfigError("Error while evaluating expression: " + String(ex.what()))
|
||||
|
|
Loading…
Reference in New Issue