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

Function HandleWalletError

src/wallet/rpc/util.cpp:126–151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

124}
125
126void HandleWalletError(const std::shared_ptr<CWallet> wallet, DatabaseStatus& status, bilingual_str& error)
127{
128 if (!wallet) {
129 // Map bad format to not found, since bad format is returned when the
130 // wallet directory exists, but doesn't contain a data file.
131 RPCErrorCode code = RPC_WALLET_ERROR;
132 switch (status) {
133 case DatabaseStatus::FAILED_NOT_FOUND:
134 case DatabaseStatus::FAILED_BAD_FORMAT:
135 code = RPC_WALLET_NOT_FOUND;
136 break;
137 case DatabaseStatus::FAILED_ALREADY_LOADED:
138 code = RPC_WALLET_ALREADY_LOADED;
139 break;
140 case DatabaseStatus::FAILED_ALREADY_EXISTS:
141 code = RPC_WALLET_ALREADY_EXISTS;
142 break;
143 case DatabaseStatus::FAILED_INVALID_BACKUP_FILE:
144 code = RPC_INVALID_PARAMETER;
145 break;
146 default: // RPC_WALLET_ERROR is returned for all other cases.
147 break;
148 }
149 throw JSONRPCError(code, error.original);
150 }
151}
152} // namespace wallet

Callers 2

restorewalletFunction · 0.85
loadwalletFunction · 0.85

Calls 1

JSONRPCErrorFunction · 0.85

Tested by

no test coverage detected