From 7a4ba59961041f6bea4a1b3baa2d93c6184013c0 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 23 Oct 2024 13:06:12 +0200 Subject: [PATCH] Remove redundant "Validation failed" prefix from ValidationError exceptions ValidationError#ValidationError() already prefixes #m_What, which #what() returns, with "Validation failed for object". --- lib/icinga/command.cpp | 2 +- lib/icinga/notification.cpp | 2 +- lib/icingadb/icingadb.cpp | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/icinga/command.cpp b/lib/icinga/command.cpp index 8e0f357e76a..ef6676b05f7 100644 --- a/lib/icinga/command.cpp +++ b/lib/icinga/command.cpp @@ -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")) { diff --git a/lib/icinga/notification.cpp b/lib/icinga/notification.cpp index ab8d42b8c96..81a48bada84 100644 --- a/lib/icinga/notification.cpp +++ b/lib/icinga/notification.cpp @@ -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(), "Validation failed: No users/user_groups specified.")); + BOOST_THROW_EXCEPTION(ValidationError(this, std::vector(), "No users/user_groups specified.")); } void Notification::ValidateStates(const Lazy& lvalue, const ValidationUtils& utils) diff --git a/lib/icingadb/icingadb.cpp b/lib/icingadb/icingadb.cpp index 6d5ded9cfa9..b9b4409396b 100644 --- a/lib/icingadb/icingadb.cpp +++ b/lib/icingadb/icingadb.cpp @@ -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(), "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(), "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("Validation failed: ") + e.what())); + BOOST_THROW_EXCEPTION(ValidationError(this, std::vector(), e.what())); } }