failure icon indicating copy to clipboard operation
failure copied to clipboard

chain_display with alternate format for linebreaks and backtraces

Open dekellum opened this issue 7 years ago • 1 comments

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 avatar Aug 15 '18 18:08 dekellum

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.

dekellum avatar Aug 16 '18 18:08 dekellum