MCPcopy Create free account
hub / github.com/ElementsProject/elements / ParseError

Function ParseError

src/bitcoin-cli.cpp:877–895  ·  view source on GitHub ↗

Parse UniValue error to update the message to print to std::cerr and the code to return. */

Source from the content-addressed store, hash-verified

875
876/** Parse UniValue error to update the message to print to std::cerr and the code to return. */
877static void ParseError(const UniValue& error, std::string& strPrint, int& nRet)
878{
879 if (error.isObject()) {
880 const UniValue& err_code = find_value(error, "code");
881 const UniValue& err_msg = find_value(error, "message");
882 if (!err_code.isNull()) {
883 strPrint = "error code: " + err_code.getValStr() + "\n";
884 }
885 if (err_msg.isStr()) {
886 strPrint += ("error message:\n" + err_msg.get_str());
887 }
888 if (err_code.isNum() && err_code.get_int() == RPC_WALLET_NOT_SPECIFIED) {
889 strPrint += "\nTry adding \"-rpcwallet=<filename>\" option to elements-cli command line.";
890 }
891 } else {
892 strPrint = "error: " + error.write();
893 }
894 nRet = abs(error["code"].get_int());
895}
896
897/**
898 * GetWalletBalances calls listwallets; if more than one wallet is loaded, it then

Callers 1

CommandLineRPCFunction · 0.85

Calls 6

isObjectMethod · 0.80
isStrMethod · 0.80
isNumMethod · 0.80
get_intMethod · 0.80
isNullMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected