Skip to content
This repository has been archived by the owner on Aug 16, 2021. It is now read-only.

chain_display with alternate format for linebreaks and backtraces #244

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

dekellum
Copy link

@dekellum dekellum commented Aug 15, 2018

This is a riff on #233, prototype based on discussions of that PR.

  • Uses chain_display() -> ChainDisplay as rename of display() -> FailDisplay

  • Adds a convenient top level failure::chain_display function, which simplifies usage (see examples/simple changes).

  • Uses single line format for "{}" and multiple lines with backtraces for (alternate == true) "{:#}".

  • Propagates alternate format selection to Fail types Display::fmt.

  • Extends examples/simple.rs with all output variants. (There is not unit or doctests yet to riff on.)

  • Adds a example/custom.rs which might demonstrate a typical double (but not particularly harmful) output of an inner error, based on current usage.

@dekellum
Copy link
Author

dekellum commented Aug 16, 2018

As another improvement (beyond #233) add (as of 37dafed) a Debug implementation for ChainDisplay as well.

Formal rationale: As Fail requires Debug, so should ChainDisplay be Debug.

Practical reasoning: Users are likely to want this when println! debugging applications.

Like with the alternate Display format, Debug formatting is propagated to each Fail in the chain.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants