API: Fix error message with PUT requests for existing objects

fixes #11396
This commit is contained in:
Michael Friedrich 2016-05-09 15:08:35 +02:00 committed by Gunnar Beutner
parent d82db2ae6c
commit 83985f97af
1 changed files with 4 additions and 2 deletions

View File

@ -111,8 +111,10 @@ bool ConfigObjectUtility::CreateObject(const Type::Ptr& type, const String& full
String path = GetObjectConfigPath(type, fullName);
Utility::MkDirP(Utility::DirName(path), 0700);
if (Utility::PathExists(path))
BOOST_THROW_EXCEPTION(ScriptError("Configuration file '" + path + "' already exists."));
if (Utility::PathExists(path)) {
errors->Add("Configuration file '" + path + "' already exists.");
return false;
}
std::ofstream fp(path.CStr(), std::ofstream::out | std::ostream::trunc);
fp << config;