-
Notifications
You must be signed in to change notification settings - Fork 416
Open
Labels
good first issueGood for newcomersGood for newcomers
Description
Currently, the Display implementation for LoadError displaysDebug output for LoadError::MissingDescriptor and LoadError::Mismatch:
impl fmt::Display for LoadError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
LoadError::Descriptor(e) => e.fmt(f),
LoadError::MissingNetwork => write!(f, "loaded data is missing network type"),
LoadError::MissingGenesis => write!(f, "loaded data is missing genesis hash"),
LoadError::MissingDescriptor(k) => {
write!(f, "loaded data is missing descriptor for keychain {k:?}")
}
LoadError::Mismatch(mismatch) => write!(f, "data mismatch: {mismatch:?}"),
}
}
}I think this is generally not a good practice. Debug output is automatically generated, and is not as nice to read as a hand-written Display implementation's output.
I noticed this in a test we were loading a wallet with the incorrect network, and instead of getting a nice error message, we got data mismatch: Network { loaded: Network::Testnet, expected: Network::Bitcoin }. Our project never exposes Debug output to the user, and we'd like to avoid doing this if we use BDK, but still be able to expose BDK errors to the user via Display.
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomers
Type
Projects
Status
Todo