From beeddb6840da9897b2872ff1b4347bd424688450 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Fri, 15 Mar 2013 11:18:02 +0100 Subject: [PATCH] Don't validate config items if we've already encountered an error. --- icinga-app/icinga.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/icinga-app/icinga.cpp b/icinga-app/icinga.cpp index af5c566fc..2350259d1 100644 --- a/icinga-app/icinga.cpp +++ b/icinga-app/icinga.cpp @@ -49,16 +49,27 @@ static bool LoadConfigFiles(bool validateOnly) } String name, fragment; - BOOST_FOREACH(tie(name, fragment), ConfigCompiler::GetConfigFragments()) { + BOOST_FOREACH(tie(name, fragment), ConfigFragmentRegistry::GetInstance()->GetItems()) { ConfigCompiler::CompileText(name, fragment); } ConfigCompilerContext::SetContext(NULL); - context.Validate(); - bool hasError = false; + BOOST_FOREACH(const ConfigCompilerError& error, context.GetErrors()) { + if (!error.Warning) { + hasError = true; + break; + } + } + + /* Don't validate if we have already encountered at least one error. */ + if (!hasError) + context.Validate(); + + hasError = false; + BOOST_FOREACH(const ConfigCompilerError& error, context.GetErrors()) { if (error.Warning) { Logger::Write(LogWarning, "icinga-app", "Config warning: " + error.Message); -- 2.40.0