Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion crates/floresta-chain/src/pruned_utreexo/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,29 @@ impl_error_from!(BlockchainError, StumpError, UtreexoError);

impl Display for BlockchainError {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(f, "{self:?}")
match self {
BlockchainError::BlockNotPresent => write!(f, "Block not found in the chain"),
BlockchainError::OrphanOrInvalidBlock => {
write!(f, "Block is either orphan or invalid")
}
BlockchainError::Parsing(msg) => write!(f, "Parsing error: {msg}"),
BlockchainError::BlockValidation(e) => write!(f, "Block validation failed: {e}"),
BlockchainError::TransactionError(e) => write!(f, "{e}"),
BlockchainError::InvalidProof => write!(f, "Invalid Utreexo proof"),
BlockchainError::UtreexoError(e) => write!(f, "Utreexo accumulator error: {e:?}"),
BlockchainError::UtreexoLeaf(e) => write!(f, "Utreexo leaf error: {e}"),
BlockchainError::Database(e) => write!(f, "Database error: {e:?}"),
Copy link
Copy Markdown
Member

@Davidson-Souza Davidson-Souza Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Database error doesn't implement Display? It would be nice if it did

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, addressed in 5208a5c. added Display as a supertrait on DatabaseError and implemented it for FlatChainstoreError (the only concrete impl), so BlockchainError::Database now formats via Display ({e}) instead of Debug.

BlockchainError::ConsensusDecode(e) => write!(f, "Consensus decoding error: {e}"),
BlockchainError::ChainNotInitialized => write!(f, "Chain is not initialized"),
BlockchainError::InvalidTip(msg) => write!(f, "Invalid chain tip: {msg}"),
BlockchainError::Io(e) => write!(f, "I/O error: {e}"),
BlockchainError::UnsupportedNetwork(net) => {
write!(f, "Unsupported network: {net}")
}
BlockchainError::BadValidationIndex => {
write!(f, "Validation index is out of range")
}
}
}
}

Expand Down
9 changes: 8 additions & 1 deletion crates/floresta-compact-filters/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,14 @@ impl From<std::io::Error> for IterableFilterStoreError {

impl Display for IterableFilterStoreError {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
Debug::fmt(self, f)
match self {
IterableFilterStoreError::Io(e) => write!(f, "I/O error: {e}"),
IterableFilterStoreError::Eof => write!(f, "Unexpected end of file"),
IterableFilterStoreError::Poisoned => write!(f, "Lock poisoned"),
IterableFilterStoreError::FilterTooLarge => {
write!(f, "Filter exceeds maximum allowed size")
}
}
}
}

Expand Down
Loading