Skip to content

Conversation

@Kile-Asmussen
Copy link
Contributor

This PR adds two probably quite useful attachment handlers:

  • Hidden for entirely hidden attachments
  • Opaque for attachments that are unimportant

It changes the behavior of Debug:

  • The Debug handler no longer prefers using its display formatter. Formatting a report as {:?} with context/attachments using the Debug handler now prints the fmt::Debug text.
  • A new handler RedactDebug has been added which prefers its display formatter, i.e. redacting the internal information, even when a report is formatted as {:?}.

It also introduces the concept of an attachment handler combinator, a simple wrapper type for another handler that adds something extra:

  • Rendering with inline headers
  • Rendering as appendixes
  • Changing priority
  • Using debug formatting for display
  • (Technically Opaque is a combinator, but will probably not be used as one very often)

Whether any of these are useful enough to belong in the main library is up for debate.

/// let output = format!("{}", report);
/// assert!(output.contains("Some(42)"));
/// ```
pub struct AlwaysDebug<H = Debug>(PhantomData<H>);

Choose a reason for hiding this comment

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

What are your thoughts on naming this ForceDebug?

Copy link

@mkatychev mkatychev Jan 5, 2026

Choose a reason for hiding this comment

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

Thank you so much for adding this, it looks great!

Through my usage of .attach_custom::<Any, _>(some_t) this past week, it feels much less ergonomic to type out than something like .attach_opaque(some_t) especially if one is chaining multiple .attach_customs at once.

Do you have any thoughts on a ReportExt that would include methods for handlers included with error stack?

  • attach_any
  • attach_opaque
  • attach_hidden
  • attach_with_header
  • attach_debug

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants