mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-24 21:15:58 +00:00
Regularize irregular results for websocket interface too.
This commit is contained in:
@@ -2154,23 +2154,7 @@ Json::Value RPCHandler::doRpcCommand(const std::string& strCommand, Json::Value&
|
|||||||
|
|
||||||
jvRequest["command"] = strCommand;
|
jvRequest["command"] = strCommand;
|
||||||
|
|
||||||
Json::Value jvResult;
|
Json::Value jvResult = doCommand(jvRequest, iRole);
|
||||||
|
|
||||||
Json::Value jvRaw = doCommand(jvRequest, iRole);
|
|
||||||
|
|
||||||
// Regularize result.
|
|
||||||
if (jvRaw.isObject())
|
|
||||||
{
|
|
||||||
// Got an object.
|
|
||||||
jvResult = jvRaw;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Probably got a string.
|
|
||||||
jvResult = Json::Value(Json::objectValue);
|
|
||||||
|
|
||||||
jvResult["message"] = jvRaw;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Always report "status". On an error report the request as received.
|
// Always report "status". On an error report the request as received.
|
||||||
if (jvResult.isMember("error"))
|
if (jvResult.isMember("error"))
|
||||||
@@ -2306,7 +2290,23 @@ cLog(lsDEBUG) << "params.size: " << jvParams.size() << " array: " << jvParams.is
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
return (this->*(commandsA[i].dfpFunc))(jvParams);
|
Json::Value jvRaw = (this->*(commandsA[i].dfpFunc))(jvParams);
|
||||||
|
|
||||||
|
// Regularize result.
|
||||||
|
if (jvRaw.isObject())
|
||||||
|
{
|
||||||
|
// Got an object.
|
||||||
|
return jvRaw;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Probably got a string.
|
||||||
|
Json::Value jvResult(Json::objectValue);
|
||||||
|
|
||||||
|
jvResult["message"] = jvRaw;
|
||||||
|
|
||||||
|
return jvResult;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (std::exception& e)
|
catch (std::exception& e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ Json::Value WSConnection::invokeCommand(Json::Value& jvRequest)
|
|||||||
// consistent.
|
// consistent.
|
||||||
//
|
//
|
||||||
// Regularize result. This is duplicate code.
|
// Regularize result. This is duplicate code.
|
||||||
if (jvResult["result"].isObject() && jvResult["result"].isMember("error"))
|
if (jvResult["result"].isMember("error"))
|
||||||
{
|
{
|
||||||
jvResult = jvResult["result"];
|
jvResult = jvResult["result"];
|
||||||
jvResult["status"] = "error";
|
jvResult["status"] = "error";
|
||||||
|
|||||||
Reference in New Issue
Block a user