Skip to content

fix(chain,compact-filters): replace Debug delegation in Display impls with per-variant messages#937

Open
none34829 wants to merge 2 commits intogetfloresta:masterfrom
none34829:fix/display-debug-delegation
Open

fix(chain,compact-filters): replace Debug delegation in Display impls with per-variant messages#937
none34829 wants to merge 2 commits intogetfloresta:masterfrom
none34829:fix/display-debug-delegation

Conversation

@none34829
Copy link
Copy Markdown

Description

BlockchainError and IterableFilterStoreError both implement Display by delegating to Debug:

// floresta-chain: BlockchainError
impl Display for BlockchainError {
    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
        write!(f, "{self:?}")
    }
}

// floresta-compact-filters: IterableFilterStoreError
impl Display for IterableFilterStoreError {
    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
        Debug::fmt(self, f)
    }
}

This produces machine-oriented output that is unsuitable for user-facing error messages and cannot be composed with thiserror's #[error(transparent)] in a meaningful way.

Changes

Replaced both with explicit match arms producing human-readable messages for each variant. Inner types that already implement Display are formatted with {}, while StumpError and Box<dyn DatabaseError> (which only implement Debug) continue to use {:?}.

This is complementary to PR #879, which adds Display impls to error types that have none. This PR improves types that already have a Display impl but delegate it to Debug.

Files changed

  • crates/floresta-chain/src/pruned_utreexo/error.rsBlockchainError (15 variants)
  • crates/floresta-compact-filters/src/lib.rsIterableFilterStoreError (4 variants)

Contributes to #667.

… with proper per-variant messages

BlockchainError and IterableFilterStoreError both implemented Display
by delegating to Debug (write!(f, "{self:?}") and Debug::fmt(self, f)
respectively). This produces machine-oriented output unsuitable for
user-facing error messages or for composition with thiserror's
#[error(transparent)].

Replace both with explicit match arms that produce human-readable
messages for each variant. Inner types that already implement Display
are formatted with {}, while StumpError and Box<dyn DatabaseError>
(which only implement Debug) continue to use {:?}.

Contributes to getfloresta#667.
@Davidson-Souza Davidson-Souza added the reliability Related to runtime reliability, stability and production readiness label Apr 7, 2026
@github-project-automation github-project-automation bot moved this to Backlog in Floresta Apr 7, 2026
@Davidson-Souza Davidson-Souza moved this from Backlog to Needs review in Floresta Apr 7, 2026
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

reliability Related to runtime reliability, stability and production readiness

Projects

Status: Needs review

Development

Successfully merging this pull request may close these issues.

2 participants