Crates.io | bare_err_tree_proc |
lib.rs | bare_err_tree_proc |
version | 0.2.3 |
source | src |
created_at | 2024-09-21 20:27:06.338355 |
updated_at | 2024-09-23 15:53:28.582331 |
description | Display errors as a formatted tree |
homepage | |
repository | https://github.com/Bennett-Petzold/bare_err_tree |
max_upload_size | |
id | 1382450 |
size | 60,939 |
bare_err_tree
is a no_std
library to print a standard Error
with a tree of sources.
Support for the extra information prints does not change the type or public API (besides a hidden field or deref).
It is added via macro or manual implementation of the AsErrTree
trait (see
the docs for details).
End users can then use tree_unwrap
or print_tree
to get better error output.
Unlike anyhow, eyre, or error-stack, the extra
functionality does not require exposing a special type in a library's API.
A library can use bare_err_tree
for its errors without changing any types,
and library users can ignore the the existence of this crate entirely. There is
also support for including any implementor of Error
in the tree with less
information, so it works on top of std and other libraries.
The formatting is borrowed from from error-stack. Please see the contributors page for appropriate credit.
Generate with cd testing; cargo run --bin example
.
missed class
├─ at testing/src/bin/example.rs:25:6
│
╰─▶ stayed in bed too long
├─ at testing/src/bin/example.rs:17:57
│
├─▶ bed is comfortable
│
╰─▶ went to sleep at 2 A.M.
├─ at testing/src/bin/example.rs:17:72
│
├─▶ finishing a project
│ │
│ ╰─▶ proving 1 == 2
│
├─▶ stressed about exams
│
╰─▶ playing video games
Generate with cd testing_trace; cargo run --bin trace_example
.
missed class
├─ at testing_trace/src/bin/trace_example.rs:44:6
│
├─ tracing frame 0 => trace_example::run_fatal
│ at testing_trace/src/bin/trace_example.rs:31
│
╰─▶ stayed in bed too long
├─ at testing_trace/src/bin/trace_example.rs:33:57
│
├─ tracing frame 1 => trace_example::new with
│ bed_time=BedTime {
│ hour: 2,
│ reasons: [
│ FinishingProject(
│ ClassProject {
│ desc: "proving 1 == 2"
│ }
│ ),
│ ExamStressed,
│ PlayingGames
│ ]
│ }
│ _garbage=5
│ at testing_trace/src/bin/trace_example.rs:117
├─ 1 duplicate tracing frame(s): [0]
│
├─▶ bed is comfortable
│
╰─▶ went to sleep at 2 A.M.
├─ at testing_trace/src/bin/trace_example.rs:34:9
│
├─ 1 duplicate tracing frame(s): [0]
│
├─▶ finishing a project
│ │
│ ╰─▶ proving 1 == 2
│
├─▶ stressed about exams
│
╰─▶ playing video games