# HG changeset patch # User Lucas Thompson # Date 1486120347 0 # Node ID bd543e74a9bf0f6480c51772e08d7969c55d4888 # Parent 0e13b7b8046459d6cd913bdbe28fe0604b371da8 Correct the inspection of the JSON object in successful to look for both error and success objects, writing out an error string if neither are present. Revert error handling in readInput() for JSON. diff -r 0e13b7b80464 -r bd543e74a9bf vamp-json/VampJson.h --- a/vamp-json/VampJson.h Fri Feb 03 11:09:37 2017 +0000 +++ b/vamp-json/VampJson.h Fri Feb 03 11:12:27 2017 +0000 @@ -1109,11 +1109,14 @@ static bool successful(json11::Json j, std::string &err) { - if (!j["result"].is_object()) { - err = "result object expected for success"; + if (j["result"].is_object()) { + return true; + } else if (j["error"].is_object()) { + return false; + } else { + err = "result or error object required for valid response"; return false; } - return true; } static void diff -r 0e13b7b80464 -r bd543e74a9bf vamp-server/convert.cpp --- a/vamp-server/convert.cpp Fri Feb 03 11:09:37 2017 +0000 +++ b/vamp-server/convert.cpp Fri Feb 03 11:12:27 2017 +0000 @@ -558,15 +558,8 @@ if (format == "json") { string err; auto result = readInputJson(direction, err, eof); - const bool isRecognisedError = !result.success && result.errorText != ""; - - // if the RequestOrResponse (result) has been populated with success=false and an error message - // then the server returned a well formed error, it is safe to return it for conversion - // -- but if err is populated, something else has gone wrong - if (isRecognisedError || err == "") - return result; - else - throw runtime_error(err); + if (err != "") throw runtime_error(err); + else return result; } else if (format == "capnp") { return readInputCapnp(direction, eof); } else {