Merge pull request #10201 from Icinga/Validation-failed

Remove redundant "Validation failed" prefix from ValidationError exceptions
This commit is contained in:
Alexander Aleksandrovič Klimov 2024-10-31 12:30:39 +01:00 committed by GitHub
commit 5f487aff1b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 5 deletions

View File

@ -35,7 +35,7 @@ void Command::Validate(int types, const ValidationUtils& utils)
Value argvalue = argdict->Get("value"); Value argvalue = argdict->Get("value");
if (argvalue.IsString() && !MacroProcessor::ValidateMacroString(argvalue)) if (argvalue.IsString() && !MacroProcessor::ValidateMacroString(argvalue))
BOOST_THROW_EXCEPTION(ValidationError(this, { "arguments", kv.first, "value" }, "Validation failed: Closing $ not found in macro format string '" + argvalue + "'.")); BOOST_THROW_EXCEPTION(ValidationError(this, { "arguments", kv.first, "value" }, "Closing $ not found in macro format string '" + argvalue + "'."));
} }
if (argdict->Contains("set_if")) { if (argdict->Contains("set_if")) {

View File

@ -739,7 +739,7 @@ void Notification::Validate(int types, const ValidationUtils& utils)
Array::Ptr groups = GetUserGroupsRaw(); Array::Ptr groups = GetUserGroupsRaw();
if ((!users || users->GetLength() == 0) && (!groups || groups->GetLength() == 0)) if ((!users || users->GetLength() == 0) && (!groups || groups->GetLength() == 0))
BOOST_THROW_EXCEPTION(ValidationError(this, std::vector<String>(), "Validation failed: No users/user_groups specified.")); BOOST_THROW_EXCEPTION(ValidationError(this, std::vector<String>(), "No users/user_groups specified."));
} }
void Notification::ValidateStates(const Lazy<Array::Ptr>& lvalue, const ValidationUtils& utils) void Notification::ValidateStates(const Lazy<Array::Ptr>& lvalue, const ValidationUtils& utils)

View File

@ -48,14 +48,13 @@ void IcingaDB::Validate(int types, const ValidationUtils& utils)
return; return;
if (GetEnableTls() && GetCertPath().IsEmpty() != GetKeyPath().IsEmpty()) { if (GetEnableTls() && GetCertPath().IsEmpty() != GetKeyPath().IsEmpty()) {
BOOST_THROW_EXCEPTION(ValidationError(this, std::vector<String>(), "Validation failed: Either both a client certificate (cert_path) and its private key (key_path) or none of them must be given.")); BOOST_THROW_EXCEPTION(ValidationError(this, std::vector<String>(), "Either both a client certificate (cert_path) and its private key (key_path) or none of them must be given."));
} }
try { try {
InitEnvironmentId(); InitEnvironmentId();
} catch (const std::exception& e) { } catch (const std::exception& e) {
BOOST_THROW_EXCEPTION(ValidationError(this, std::vector<String>(), BOOST_THROW_EXCEPTION(ValidationError(this, std::vector<String>(), e.what()));
String("Validation failed: ") + e.what()));
} }
} }