mirror of https://github.com/Icinga/icinga2.git
Handle errors when evaluating --define
This can be observed when running something like `icinga2 daemon -C -DTypes.Host=42`. Without this commit: [2023-02-01 09:29:00 +0100] critical/Application: Error: Namespace is read-only and must not be modified. Additional information is available in '/var/log/icinga2/crash/report.1675240140.425155' With this commit: [2023-02-01 09:30:37 +0100] critical/icinga-app: cannot set 'Types.Host': Namespace is read-only and must not be modified.
This commit is contained in:
parent
a24375bc91
commit
d2fb8a9181
|
@ -427,8 +427,13 @@ static int Main()
|
||||||
std::unique_ptr<SetExpression> setExpr{new SetExpression(std::move(expr), OpSetLiteral, MakeLiteral(value))};
|
std::unique_ptr<SetExpression> setExpr{new SetExpression(std::move(expr), OpSetLiteral, MakeLiteral(value))};
|
||||||
setExpr->SetOverrideFrozen();
|
setExpr->SetOverrideFrozen();
|
||||||
|
|
||||||
|
try {
|
||||||
ScriptFrame frame(true);
|
ScriptFrame frame(true);
|
||||||
setExpr->Evaluate(frame);
|
setExpr->Evaluate(frame);
|
||||||
|
} catch (const ScriptError& e) {
|
||||||
|
Log(LogCritical, "icinga-app") << "cannot set '" << key << "': " << e.what();
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue