Improve error messages for apply rules

refs #6070
This commit is contained in:
Gunnar Beutner 2014-10-10 11:39:03 +02:00
parent 8fa7bde4da
commit 5962330b27
4 changed files with 57 additions and 14 deletions

View File

@ -21,11 +21,13 @@
#include "icinga/service.hpp"
#include "config/configitembuilder.hpp"
#include "config/applyrule.hpp"
#include "config/configcompilercontext.hpp"
#include "base/initialize.hpp"
#include "base/dynamictype.hpp"
#include "base/logger_fwd.hpp"
#include "base/context.hpp"
#include "base/workqueue.hpp"
#include "base/configerror.hpp"
#include <boost/foreach.hpp>
using namespace icinga;
@ -115,8 +117,13 @@ void Dependency::EvaluateApplyRule(const ApplyRule& rule)
BOOST_FOREACH(const Host::Ptr& host, DynamicType::GetObjectsByType<Host>()) {
CONTEXT("Evaluating 'apply' rules for host '" + host->GetName() + "'");
if (EvaluateApplyRuleOne(host, rule))
apply_count++;
try {
if (EvaluateApplyRuleOne(host, rule))
apply_count++;
} catch (const ConfigError& ex) {
const DebugInfo *di = boost::get_error_info<errinfo_debuginfo>(ex);
ConfigCompilerContext::GetInstance()->AddMessage(true, ex.what(), di ? *di : DebugInfo());
}
}
if (apply_count == 0)
@ -128,8 +135,13 @@ void Dependency::EvaluateApplyRule(const ApplyRule& rule)
BOOST_FOREACH(const Service::Ptr& service, DynamicType::GetObjectsByType<Service>()) {
CONTEXT("Evaluating 'apply' rules for Service '" + service->GetName() + "'");
if (EvaluateApplyRuleOne(service, rule))
apply_count++;
try {
if (EvaluateApplyRuleOne(service, rule))
apply_count++;
} catch (const ConfigError& ex) {
const DebugInfo *di = boost::get_error_info<errinfo_debuginfo>(ex);
ConfigCompilerContext::GetInstance()->AddMessage(true, ex.what(), di ? *di : DebugInfo());
}
}
if (apply_count == 0)

View File

@ -21,11 +21,13 @@
#include "icinga/service.hpp"
#include "config/configitembuilder.hpp"
#include "config/applyrule.hpp"
#include "config/configcompilercontext.hpp"
#include "base/initialize.hpp"
#include "base/dynamictype.hpp"
#include "base/logger_fwd.hpp"
#include "base/context.hpp"
#include "base/workqueue.hpp"
#include "base/configerror.hpp"
#include <boost/foreach.hpp>
using namespace icinga;
@ -110,8 +112,13 @@ void Notification::EvaluateApplyRule(const ApplyRule& rule)
BOOST_FOREACH(const Host::Ptr& host, DynamicType::GetObjectsByType<Host>()) {
CONTEXT("Evaluating 'apply' rules for host '" + host->GetName() + "'");
if (EvaluateApplyRuleOne(host, rule))
apply_count++;
try {
if (EvaluateApplyRuleOne(host, rule))
apply_count++;
} catch (const ConfigError& ex) {
const DebugInfo *di = boost::get_error_info<errinfo_debuginfo>(ex);
ConfigCompilerContext::GetInstance()->AddMessage(true, ex.what(), di ? *di : DebugInfo());
}
}
if (apply_count == 0)
@ -123,8 +130,13 @@ void Notification::EvaluateApplyRule(const ApplyRule& rule)
BOOST_FOREACH(const Service::Ptr& service, DynamicType::GetObjectsByType<Service>()) {
CONTEXT("Evaluating 'apply' rules for Service '" + service->GetName() + "'");
if (EvaluateApplyRuleOne(service, rule))
apply_count++;
try {
if (EvaluateApplyRuleOne(service, rule))
apply_count++;
} catch (const ConfigError& ex) {
const DebugInfo *di = boost::get_error_info<errinfo_debuginfo>(ex);
ConfigCompilerContext::GetInstance()->AddMessage(true, ex.what(), di ? *di : DebugInfo());
}
}
if (apply_count == 0)

View File

@ -21,10 +21,12 @@
#include "icinga/service.hpp"
#include "config/configitembuilder.hpp"
#include "config/applyrule.hpp"
#include "config/configcompilercontext.hpp"
#include "base/initialize.hpp"
#include "base/dynamictype.hpp"
#include "base/logger_fwd.hpp"
#include "base/context.hpp"
#include "base/configerror.hpp"
#include <boost/foreach.hpp>
using namespace icinga;
@ -110,8 +112,13 @@ void ScheduledDowntime::EvaluateApplyRules(const std::vector<ApplyRule>& rules)
BOOST_FOREACH(const Host::Ptr& host, DynamicType::GetObjectsByType<Host>()) {
CONTEXT("Evaluating 'apply' rules for host '" + host->GetName() + "'");
if (EvaluateApplyRule(host, rule))
apply_count++;
try {
if (EvaluateApplyRule(host, rule))
apply_count++;
} catch (const ConfigError& ex) {
const DebugInfo *di = boost::get_error_info<errinfo_debuginfo>(ex);
ConfigCompilerContext::GetInstance()->AddMessage(true, ex.what(), di ? *di : DebugInfo());
}
}
if (apply_count == 0)
@ -123,8 +130,13 @@ void ScheduledDowntime::EvaluateApplyRules(const std::vector<ApplyRule>& rules)
BOOST_FOREACH(const Service::Ptr& service, DynamicType::GetObjectsByType<Service>()) {
CONTEXT("Evaluating 'apply' rules for Service '" + service->GetName() + "'");
if(EvaluateApplyRule(service, rule))
apply_count++;
try {
if(EvaluateApplyRule(service, rule))
apply_count++;
} catch (const ConfigError& ex) {
const DebugInfo *di = boost::get_error_info<errinfo_debuginfo>(ex);
ConfigCompilerContext::GetInstance()->AddMessage(true, ex.what(), di ? *di : DebugInfo());
}
}
if (apply_count == 0)

View File

@ -20,11 +20,13 @@
#include "icinga/service.hpp"
#include "config/configitembuilder.hpp"
#include "config/applyrule.hpp"
#include "config/configcompilercontext.hpp"
#include "base/initialize.hpp"
#include "base/dynamictype.hpp"
#include "base/logger_fwd.hpp"
#include "base/context.hpp"
#include "base/workqueue.hpp"
#include "base/configerror.hpp"
#include <boost/foreach.hpp>
using namespace icinga;
@ -97,8 +99,13 @@ void Service::EvaluateApplyRule(const ApplyRule& rule)
BOOST_FOREACH(const Host::Ptr& host, DynamicType::GetObjectsByType<Host>()) {
CONTEXT("Evaluating 'apply' rules for host '" + host->GetName() + "'");
if (EvaluateApplyRuleOne(host, rule))
apply_count++;
try {
if (EvaluateApplyRuleOne(host, rule))
apply_count++;
} catch (const ConfigError& ex) {
const DebugInfo *di = boost::get_error_info<errinfo_debuginfo>(ex);
ConfigCompilerContext::GetInstance()->AddMessage(true, ex.what(), di ? *di : DebugInfo());
}
}
if (apply_count == 0)