Parse UniValue error to update the message to print to std::cerr and the code to return. */
| 875 | |
| 876 | /** Parse UniValue error to update the message to print to std::cerr and the code to return. */ |
| 877 | static 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 |