Mercurial > hg > piper-cpp
diff vamp-server/convert.cpp @ 184:150cfa0c71e1
Merge pull request #1 from piper-audio/fix/regression-json-responses
Fix/regression json responses
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Fri, 03 Feb 2017 13:00:42 +0000 |
parents | bd543e74a9bf |
children | df381a2e6fa1 |
line wrap: on
line diff
--- a/vamp-server/convert.cpp Tue Jan 31 18:05:11 2017 +0000 +++ b/vamp-server/convert.cpp Fri Feb 03 13:00:42 2017 +0000 @@ -295,8 +295,10 @@ VampJson::BufferSerialisation serialisation = VampJson::BufferSerialisation::Array; - rr.success = j["success"].bool_value(); - rr.errorText = j["errorText"].string_value(); + const bool isSuccess = j["result"].is_object(); + const bool isError = j["error"].is_object(); + rr.success = isSuccess; + rr.errorText = isError ? j["error"]["message"].string_value() : ""; switch (rr.type) { @@ -335,11 +337,11 @@ Json id = writeJsonId(rr.id); if (!rr.success) { - - j = VampJson::fromError(rr.errorText, rr.type, id); + // errorText here likely contains a full message produced by simple-server + // setting writeVerbatimError to true avoids doubling error descriptions + j = VampJson::fromError(rr.errorText, rr.type, id, true); } else { - switch (rr.type) { case RRType::List: @@ -659,7 +661,6 @@ writeOutput(outformat, rr); } catch (std::exception &e) { - cerr << "Error: " << e.what() << endl; exit(1); }