More specific RPC error reporting.

This commit is contained in:
Arthur Britto
2013-01-16 15:03:36 -08:00
parent 0d7f8cbe13
commit 503e9a7ddc
4 changed files with 5 additions and 3 deletions

View File

@@ -21,6 +21,7 @@ Json::Value rpcError(int iError, Json::Value jvResult)
{ rpcBAD_BLOB, "badBlob", "Blob must be a non-empty hex string." },
{ rpcBAD_SEED, "badSeed", "Disallowed seed." },
{ rpcBAD_SYNTAX, "badSyntax", "Syntax error." },
{ rpcCOMMAND_MISSING, "commandMissing", "Missing command entry." },
{ rpcDST_ACT_MALFORMED, "dstActMalformed", "Destination account is malformed." },
{ rpcDST_ACT_MISSING, "dstActMissing", "Destination account does not exists." },
{ rpcDST_AMT_MALFORMED, "dstAmtMalformed", "Destination amount/currency/issuer is malformed." },

View File

@@ -45,6 +45,7 @@ enum {
rpcQUALITY_MALFORMED,
rpcBAD_BLOB,
rpcBAD_SEED,
rpcCOMMAND_MISSING,
rpcDST_ACT_MALFORMED,
rpcDST_ACT_MISSING,
rpcDST_AMT_MALFORMED,

View File

@@ -2553,10 +2553,10 @@ Json::Value RPCHandler::doInternal(Json::Value jvRequest)
return RPCInternalHandler::runHandler(jvRequest["internal_command"].asString(), jvRequest["params"]);
}
Json::Value RPCHandler::doCommand(Json::Value& jvRequest, int iRole)
Json::Value RPCHandler::doCommand(const Json::Value& jvRequest, int iRole)
{
if (!jvRequest.isMember("command"))
return rpcError(rpcINVALID_PARAMS);
return rpcError(rpcCOMMAND_MISSING);
std::string strCommand = jvRequest["command"].asString();

View File

@@ -115,7 +115,7 @@ public:
RPCHandler(NetworkOPs* netOps);
RPCHandler(NetworkOPs* netOps, InfoSub* infoSub);
Json::Value doCommand(Json::Value& jvRequest, int role);
Json::Value doCommand(const Json::Value& jvRequest, int role);
Json::Value doRpcCommand(const std::string& strCommand, Json::Value& jvParams, int iRole);
};