Skip to content

Commit

Permalink
Fix error return message in QueryHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
luisremis committed Jul 17, 2019
1 parent 105a9af commit de5cb8d
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/QueryHandler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,9 @@ void QueryHandler::process_query(protobufs::queryMessage& proto_query,
std::cerr << "End Failed Query: " << std::endl;
exception_error["info"] = error_msg.str();
exception_error["status"] = RSCommand::Error;
proto_res.set_json(fastWriter.write(exception_error));
Json::Value response;
response.append(exception_error);
proto_res.set_json(fastWriter.write(response));
};

try {
Expand Down Expand Up @@ -368,13 +370,20 @@ void QueryHandler::process_query(protobufs::queryMessage& proto_query,

Json::Value& tx_responses = pmgd_query.run();

if (tx_responses.size() != root.size()) { // error
cmd_current = "Transaction";
cmd_result = tx_responses;
cmd_result["info"] = "Failed PMGDTransaction";
if (!tx_responses.isArray() || tx_responses.size() != root.size()) {
Json::StyledWriter writer;
std::cerr << "PMGD Response:" << std::endl;
std::cerr << writer.write(tx_responses) << std::endl;

std::string tx_error_msg("Failed PMGD Transaction");
if (!tx_responses.isArray() && tx_responses.isMember("info")) {
tx_error_msg += ": " + tx_responses["info"].asString();
}

cmd_result["status"] = RSCommand::Error;
Json::StyledWriter w;
std::cerr << w.write(tx_responses);
cmd_result["info"] = tx_error_msg;

cmd_current = "Transaction";
error(cmd_result, cmd_current);
return;
}
Expand Down

0 comments on commit de5cb8d

Please sign in to comment.