the response should never be empty but we need to check the json lib for exceptions and return appropriately... + cleanup a bit - closes #33

This commit is contained in:
DarthArgus
2016-05-22 17:44:00 +00:00
parent a78fbb9978
commit a05e61e0fe
4 changed files with 22 additions and 24 deletions
+9 -1
View File
@@ -81,7 +81,15 @@ nlohmann::json webAPI::request(std::string endpoint, std::string data, int reqTy
if (res == CURLE_OK && http_code == 200 && !(readBuffer.empty())) // check it all out and parse
{
response = nlohmann::json::parse(readBuffer);
try {
response = nlohmann::json::parse(readBuffer);
} catch (std::string e) {
response["message"] = e;
response["status"] = "failure";
} catch (...) {
response["message"] = "JSON parse error for endpoint.";
response["status"] = "failure";
}
}
else
{