| 124 | } |
| 125 | |
| 126 | void 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 |
no test coverage detected