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:
+9
-1
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user