mirror of https://github.com/Icinga/icinga2.git
Fix: Detailed error message is missing when object creation via API fails
fixes #10580
This commit is contained in:
parent
9b2e4cfd28
commit
c44701068f
|
@ -64,9 +64,20 @@ bool CreateObjectHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& r
|
||||||
|
|
||||||
String config = ConfigObjectUtility::CreateObjectConfig(type, name, ignoreOnError, templates, attrs);
|
String config = ConfigObjectUtility::CreateObjectConfig(type, name, ignoreOnError, templates, attrs);
|
||||||
|
|
||||||
|
Array::Ptr results = new Array();
|
||||||
|
results->Add(result1);
|
||||||
|
|
||||||
|
Dictionary::Ptr result = new Dictionary();
|
||||||
|
result->Set("results", results);
|
||||||
|
|
||||||
if (!ConfigObjectUtility::CreateObject(type, name, config, errors)) {
|
if (!ConfigObjectUtility::CreateObject(type, name, config, errors)) {
|
||||||
result1->Set("errors", errors);
|
result1->Set("errors", errors);
|
||||||
HttpUtility::SendJsonError(response, 500, "Object could not be created.");
|
result1->Set("code", 500);
|
||||||
|
result1->Set("status", "Object could not be created.");
|
||||||
|
|
||||||
|
response.SetStatus(500, "Object could not be created");
|
||||||
|
HttpUtility::SendJsonBody(response, result);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,12 +92,6 @@ bool CreateObjectHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& r
|
||||||
else if (!obj && ignoreOnError)
|
else if (!obj && ignoreOnError)
|
||||||
result1->Set("status", "Object was not created but 'ignore_on_error' was set to true");
|
result1->Set("status", "Object was not created but 'ignore_on_error' was set to true");
|
||||||
|
|
||||||
Array::Ptr results = new Array();
|
|
||||||
results->Add(result1);
|
|
||||||
|
|
||||||
Dictionary::Ptr result = new Dictionary();
|
|
||||||
result->Set("results", results);
|
|
||||||
|
|
||||||
response.SetStatus(200, "OK");
|
response.SetStatus(200, "OK");
|
||||||
HttpUtility::SendJsonBody(response, result);
|
HttpUtility::SendJsonBody(response, result);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue