Skip to content

Commit

Permalink
feat: implement Display for LoadMismatch
Browse files Browse the repository at this point in the history
  • Loading branch information
luisschwab committed Mar 9, 2025
1 parent 6a494bd commit c9c2eb1
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions crates/wallet/src/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,28 @@ pub enum LoadMismatch {
},
}

impl fmt::Display for LoadMismatch {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
LoadMismatch::Network { loaded, expected } => {
write!(f, "Network mismatch: loaded {}, expected {}", loaded, expected)
}
LoadMismatch::Genesis { loaded, expected } => {
write!(f, "Genesis hash mismatch: loaded {}, expected {}", loaded, expected)
}
LoadMismatch::Descriptor { keychain, loaded, expected } => {
write!(
f,
"Descriptor mismatch for {} keychain: loaded {}, expected {}",
keychain,
loaded.as_ref().map_or("None".to_string(), |d| d.to_string()),
expected.as_ref().map_or("None".to_string(), |d| d.to_string())
)
}
}
}
}

impl From<LoadMismatch> for LoadError {
fn from(mismatch: LoadMismatch) -> Self {
Self::Mismatch(mismatch)
Expand Down

0 comments on commit c9c2eb1

Please sign in to comment.