Fixes #1964 to catch general exception in z_sendmany and catch
exceptions as reference-to-const.
This commit is contained in:
@@ -86,7 +86,7 @@ AsyncRPCOperation_sendmany::AsyncRPCOperation_sendmany(
|
||||
isfromzaddr_ = true;
|
||||
frompaymentaddress_ = addr;
|
||||
spendingkey_ = key;
|
||||
} catch (std::runtime_error e) {
|
||||
} catch (const std::runtime_error& e) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, string("runtime error: ") + e.what());
|
||||
}
|
||||
}
|
||||
@@ -106,17 +106,20 @@ void AsyncRPCOperation_sendmany::main() {
|
||||
|
||||
try {
|
||||
success = main_impl();
|
||||
} catch (Object objError) {
|
||||
} catch (const Object& objError) {
|
||||
int code = find_value(objError, "code").get_int();
|
||||
std::string message = find_value(objError, "message").get_str();
|
||||
set_error_code(code);
|
||||
set_error_message(message);
|
||||
} catch (runtime_error e) {
|
||||
} catch (const runtime_error& e) {
|
||||
set_error_code(-1);
|
||||
set_error_message("runtime error: " + string(e.what()));
|
||||
} catch (logic_error e) {
|
||||
} catch (const logic_error& e) {
|
||||
set_error_code(-1);
|
||||
set_error_message("logic error: " + string(e.what()));
|
||||
} catch (const exception& e) {
|
||||
set_error_code(-1);
|
||||
set_error_message("general exception: " + string(e.what()));
|
||||
} catch (...) {
|
||||
set_error_code(-2);
|
||||
set_error_message("unknown error");
|
||||
@@ -577,7 +580,7 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
||||
FormatMoney(plaintext.value, false)
|
||||
);
|
||||
|
||||
} catch (const std::exception e) {
|
||||
} catch (const std::exception& e) {
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, strprintf("Error decrypting output note of previous JoinSplit: %s", e.what()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2955,7 +2955,7 @@ Value z_listreceivedbyaddress(const Array& params, bool fHelp)
|
||||
CZCPaymentAddress address(fromaddress);
|
||||
try {
|
||||
zaddr = address.Get();
|
||||
} catch (std::runtime_error) {
|
||||
} catch (const std::runtime_error&) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid zaddr.");
|
||||
}
|
||||
|
||||
@@ -3022,7 +3022,7 @@ Value z_getbalance(const Array& params, bool fHelp)
|
||||
CZCPaymentAddress address(fromaddress);
|
||||
try {
|
||||
zaddr = address.Get();
|
||||
} catch (std::runtime_error) {
|
||||
} catch (const std::runtime_error&) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid from address, should be a taddr or zaddr.");
|
||||
}
|
||||
if (!pwalletMain->HaveSpendingKey(zaddr)) {
|
||||
@@ -3226,7 +3226,7 @@ Value z_sendmany(const Array& params, bool fHelp)
|
||||
CZCPaymentAddress address(fromaddress);
|
||||
try {
|
||||
zaddr = address.Get();
|
||||
} catch (std::runtime_error) {
|
||||
} catch (const std::runtime_error&) {
|
||||
// invalid
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid from address, should be a taddr or zaddr.");
|
||||
}
|
||||
@@ -3273,7 +3273,7 @@ Value z_sendmany(const Array& params, bool fHelp)
|
||||
CZCPaymentAddress zaddr(address);
|
||||
zaddr.Get();
|
||||
isZaddr = true;
|
||||
} catch (std::runtime_error) {
|
||||
} catch (const std::runtime_error&) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, unknown address format: ")+address );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user