aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Jahr <fabian.jahr@whu.edu>2019-07-12 14:06:55 -0400
committerFabian Jahr <fjahr@protonmail.com>2019-07-19 14:34:53 -0400
commite967cae8fac84ec7a89a3a853a83d8193ac3308e (patch)
treed5bf5a1bf54e44788884abf271aac5443dbd399b
parentba1f128d6c117a63d5d904b3956551bd83405ec9 (diff)
Use switch on status in RpcWallet
-rw-r--r--src/wallet/rpcwallet.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp
index a600331ba0..ae610ec07d 100644
--- a/src/wallet/rpcwallet.cpp
+++ b/src/wallet/rpcwallet.cpp
@@ -2686,12 +2686,14 @@ static UniValue createwallet(const JSONRPCRequest& request)
std::string warning;
std::shared_ptr<CWallet> wallet;
WalletCreationStatus status = CreateWallet(*g_rpc_interfaces->chain, passphrase, flags, request.params[0].get_str(), error, warning, wallet);
- if (status == WalletCreationStatus::CREATION_FAILED) {
- throw JSONRPCError(RPC_WALLET_ERROR, error);
- } else if (status == WalletCreationStatus::ENCRYPTION_FAILED) {
- throw JSONRPCError(RPC_WALLET_ENCRYPTION_FAILED, error);
- } else if (status != WalletCreationStatus::SUCCESS) {
- throw JSONRPCError(RPC_WALLET_ERROR, "Wallet creation failed");
+ switch (status) {
+ case WalletCreationStatus::CREATION_FAILED:
+ throw JSONRPCError(RPC_WALLET_ERROR, error);
+ case WalletCreationStatus::ENCRYPTION_FAILED:
+ throw JSONRPCError(RPC_WALLET_ENCRYPTION_FAILED, error);
+ case WalletCreationStatus::SUCCESS:
+ break;
+ // no default case, so the compiler can warn about missing cases
}
UniValue obj(UniValue::VOBJ);