Skip to content

Commit

Permalink
Merge pull request #10201 from Icinga/Validation-failed
Browse files Browse the repository at this point in the history
Remove redundant "Validation failed" prefix from ValidationError exceptions
  • Loading branch information
Al2Klimov authored Oct 31, 2024
2 parents 92399a9 + 7a4ba59 commit 5f487af
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/icinga/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void Command::Validate(int types, const ValidationUtils& utils)
Value argvalue = argdict->Get("value");

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")) {
Expand Down
2 changes: 1 addition & 1 deletion lib/icinga/notification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ void Notification::Validate(int types, const ValidationUtils& utils)
Array::Ptr groups = GetUserGroupsRaw();

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)
Expand Down
5 changes: 2 additions & 3 deletions lib/icingadb/icingadb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,13 @@ void IcingaDB::Validate(int types, const ValidationUtils& utils)
return;

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 {
InitEnvironmentId();
} catch (const std::exception& e) {
BOOST_THROW_EXCEPTION(ValidationError(this, std::vector<String>(),
String("Validation failed: ") + e.what()));
BOOST_THROW_EXCEPTION(ValidationError(this, std::vector<String>(), e.what()));
}
}

Expand Down

0 comments on commit 5f487af

Please sign in to comment.