-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Labels
A-rpc-interfaceArea: RPC interfaceArea: RPC interfaceI-error-handlingProblems and improvements related to error handlingProblems and improvements related to error handling
Description
There are three kinds of errors we need to deal with:
- Errors returned to users from CLI commands.
- Errors returned to users via JSON-RPC.
- Errors produced by internal components that are consumed by other internal components (usually by being converted to one of the other two kind of errors).
Currently we are using an ErrorKind
enum for the first type of errors and converting to the second kind as needed:
wallet/zallet/src/components/json_rpc/methods/z_send_many.rs
Lines 193 to 203 in 2eb2d4b
// Fetch spending key last, to avoid a keystore decryption if unnecessary. | |
let seed = keystore | |
.decrypt_seed(derivation.seed_fingerprint()) | |
.await | |
.map_err(|e| match e.kind() { | |
// TODO: Improve internal error types. | |
crate::error::ErrorKind::Generic if e.to_string() == "Wallet is locked" => { | |
LegacyCode::WalletUnlockNeeded.with_message(e.to_string()) | |
} | |
_ => LegacyCode::Database.with_message(e.to_string()), | |
})?; |
We should instead have comprehensive granular errors internally, and then map them to the appropriate user-facing errors at the necessary boundary.
dismad
Metadata
Metadata
Assignees
Labels
A-rpc-interfaceArea: RPC interfaceArea: RPC interfaceI-error-handlingProblems and improvements related to error handlingProblems and improvements related to error handling