Add rpcErrorString function

This commit is contained in:
Vinnie Falco
2015-05-31 11:53:25 -07:00
parent 02c118981f
commit 8adc4c1e3c
2 changed files with 14 additions and 2 deletions

View File

@@ -260,7 +260,10 @@ inline Json::Value expected_field_error (
/** Returns `true` if the json contains an rpc error specification. */ /** Returns `true` if the json contains an rpc error specification. */
bool contains_error (Json::Value const& json); bool contains_error (Json::Value const& json);
} } // RPC
/** Returns a single string with the contents of an RPC error. */
std::string rpcErrorString(Json::Value const& jv);
} }

View File

@@ -170,5 +170,14 @@ bool contains_error (Json::Value const& json)
return false; return false;
} }
} // RPC
std::string rpcErrorString(Json::Value const& jv)
{
assert(RPC::contains_error(jv));
return jv[jss::error].asString() +
jv[jss::error_message].asString();
} }
}
} // ripple