]> granicus.if.org Git - icinga2/commitdiff
Improve error messages for duplicate objects
authorGunnar Beutner <gunnar@beutner.name>
Sat, 15 Aug 2015 08:17:45 +0000 (10:17 +0200)
committerGunnar Beutner <gunnar@beutner.name>
Sat, 15 Aug 2015 18:07:12 +0000 (20:07 +0200)
refs #9101

lib/config/config_parser.yy
lib/config/configitembuilder.cpp
lib/remote/createobjecthandler.cpp

index 2e63f6f569bef8b08f9aefec2ff4d3c4b6564df0..36ee268eaea35575973b5be16d60f0197fb13a36 100644 (file)
@@ -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"
index 439573c79c51c02b89a5fe5ad2e37c3ae955b28a..5906f9ad6448c85c21ee1fb85ace82c4797eb209 100644 (file)
@@ -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) {
index 43836b4156cd273ce9755c5ca4ee2c7bd1fefff7..143d17139ffafe3bff66d4a2cce52fab3de36ec0 100644 (file)
@@ -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);