From 827de2190710253b5ddc40b1af6a64f0b486f5ab Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Sat, 15 Aug 2015 10:17:45 +0200 Subject: [PATCH] Improve error messages for duplicate objects refs #9101 --- lib/config/config_parser.yy | 1 - lib/config/configitembuilder.cpp | 8 ++++---- lib/remote/createobjecthandler.cpp | 3 +-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/config/config_parser.yy b/lib/config/config_parser.yy index 2e63f6f56..36ee268ea 100644 --- a/lib/config/config_parser.yy +++ b/lib/config/config_parser.yy @@ -21,7 +21,6 @@ ******************************************************************************/ #include "config/i2-config.hpp" -#include "config/configitembuilder.hpp" #include "config/configcompiler.hpp" #include "config/expression.hpp" #include "config/applyrule.hpp" diff --git a/lib/config/configitembuilder.cpp b/lib/config/configitembuilder.cpp index 439573c79..5906f9ad6 100644 --- a/lib/config/configitembuilder.cpp +++ b/lib/config/configitembuilder.cpp @@ -79,14 +79,14 @@ ConfigItem::Ptr ConfigItemBuilder::Compile(void) { if (m_Type.IsEmpty()) { std::ostringstream msgbuf; - msgbuf << "The type name of an object may not be empty: " << m_DebugInfo; - BOOST_THROW_EXCEPTION(std::invalid_argument(msgbuf.str())); + msgbuf << "The type name of an object may not be empty"; + BOOST_THROW_EXCEPTION(ScriptError(msgbuf.str(), m_DebugInfo)); } if (!DynamicType::GetByName(m_Type)) { std::ostringstream msgbuf; - msgbuf << "The type '" + m_Type + "' is unknown: " << m_DebugInfo; - BOOST_THROW_EXCEPTION(std::invalid_argument(msgbuf.str())); + msgbuf << "The type '" + m_Type + "' is unknown"; + BOOST_THROW_EXCEPTION(ScriptError(msgbuf.str(), m_DebugInfo)); } if (m_Name.FindFirstOf("!") != String::NPos) { diff --git a/lib/remote/createobjecthandler.cpp b/lib/remote/createobjecthandler.cpp index 43836b415..143d17139 100644 --- a/lib/remote/createobjecthandler.cpp +++ b/lib/remote/createobjecthandler.cpp @@ -105,8 +105,7 @@ bool CreateObjectHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& r status = "Object could not be created."; Array::Ptr errors = new Array(); - BOOST_FOREACH(const boost::exception_ptr& ex, upq.GetExceptions()) - { + BOOST_FOREACH(const boost::exception_ptr& ex, upq.GetExceptions()) { errors->Add(DiagnosticInformation(ex)); } result1->Set("errors", errors); -- 2.40.0