Improve error messages for duplicate objects

refs #9101
This commit is contained in:
Gunnar Beutner 2015-08-15 10:17:45 +02:00
parent 1b21faeb5d
commit 827de21907
3 changed files with 5 additions and 7 deletions

View File

@ -21,7 +21,6 @@
******************************************************************************/ ******************************************************************************/
#include "config/i2-config.hpp" #include "config/i2-config.hpp"
#include "config/configitembuilder.hpp"
#include "config/configcompiler.hpp" #include "config/configcompiler.hpp"
#include "config/expression.hpp" #include "config/expression.hpp"
#include "config/applyrule.hpp" #include "config/applyrule.hpp"

View File

@ -79,14 +79,14 @@ ConfigItem::Ptr ConfigItemBuilder::Compile(void)
{ {
if (m_Type.IsEmpty()) { if (m_Type.IsEmpty()) {
std::ostringstream msgbuf; std::ostringstream msgbuf;
msgbuf << "The type name of an object may not be empty: " << m_DebugInfo; msgbuf << "The type name of an object may not be empty";
BOOST_THROW_EXCEPTION(std::invalid_argument(msgbuf.str())); BOOST_THROW_EXCEPTION(ScriptError(msgbuf.str(), m_DebugInfo));
} }
if (!DynamicType::GetByName(m_Type)) { if (!DynamicType::GetByName(m_Type)) {
std::ostringstream msgbuf; std::ostringstream msgbuf;
msgbuf << "The type '" + m_Type + "' is unknown: " << m_DebugInfo; msgbuf << "The type '" + m_Type + "' is unknown";
BOOST_THROW_EXCEPTION(std::invalid_argument(msgbuf.str())); BOOST_THROW_EXCEPTION(ScriptError(msgbuf.str(), m_DebugInfo));
} }
if (m_Name.FindFirstOf("!") != String::NPos) { if (m_Name.FindFirstOf("!") != String::NPos) {

View File

@ -105,8 +105,7 @@ bool CreateObjectHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& r
status = "Object could not be created."; status = "Object could not be created.";
Array::Ptr errors = new Array(); 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)); errors->Add(DiagnosticInformation(ex));
} }
result1->Set("errors", errors); result1->Set("errors", errors);