packages = ConfigPackageUtility::GetPackages();
} catch (const std::exception& ex) {
HttpUtility::SendJsonError(response, params, 500, "Could not retrieve packages.",
- DiagnosticInformation(ex, false));
+ DiagnosticInformation(ex));
return;
}
ConfigPackageUtility::CreatePackage(packageName);
} catch (const std::exception& ex) {
HttpUtility::SendJsonError(response, params, 500, "Could not create package '" + packageName + "'.",
- DiagnosticInformation(ex, false));
+ DiagnosticInformation(ex));
return;
}
Dictionary::Ptr result1 = new Dictionary({
{ "code", 200 },
+ { "package", packageName },
{ "status", "Created package." }
});
return;
}
- int code = 200;
- String status = "Deleted package.";
- DictionaryData result1;
-
try {
ConfigPackageUtility::DeletePackage(packageName);
} catch (const std::exception& ex) {
- code = 500;
- status = "Failed to delete package.";
- if (HttpUtility::GetLastParameter(params, "verboseErrors"))
- result1.emplace_back("diagnostic information", DiagnosticInformation(ex));
+ HttpUtility::SendJsonError(response, params, 500, "Failed to delete package '" + packageName + "'.",
+ DiagnosticInformation(ex));
}
- result1.emplace_back("package", packageName);
- result1.emplace_back("code", code);
- result1.emplace_back("status", status);
+ Dictionary::Ptr result1 = new Dictionary({
+ { "code", 200 },
+ { "package", packageName },
+ { "status", "Created package." }
+ });
Dictionary::Ptr result = new Dictionary({
- { "results", new Array({ new Dictionary(std::move(result1)) }) }
+ { "results", new Array({ result1 }) }
});
- response.SetStatus(code, (code == 200) ? "OK" : "Internal Server Error");
+ response.SetStatus(200, "OK");
HttpUtility::SendJsonBody(response, params, result);
}