Skip to content

Commit 94e05e8

Browse files
authored
Update posts/inside-rust/2021-05-15-What-the-error-handling-project-group-is-working-towards.md
1 parent 72792ee commit 94e05e8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

posts/inside-rust/2021-05-15-What-the-error-handling-project-group-is-working-towards.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ Error: invalid config
120120

121121
By default all of the source's error messages are lost. This arises from the fact that we used `Display` as the interface to an individual error message. If we could go back we'd currently propose instead adding `fn message(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result` to the `Error` trait, but that ship has sailed.
122122

123-
The way that libraries work around this today is by abusing the `Debug` trait. Types like [`eyre`](https://docs.rs/eyre/0.6.5/eyre/trait.EyreHandler.html#tymethod.debug), [`anyhow`](https://docs.rs/anyhow/1.0.40/src/anyhow/fmt.rs.html#19), and even sometimes [`custom error enums`]() use their `Debug` output to print the full chain of errors in a human readable report.
123+
The way that libraries work around this today is by abusing the `Debug` trait. Types like [`eyre`](https://docs.rs/eyre/0.6.5/eyre/trait.EyreHandler.html#tymethod.debug), [`anyhow`](https://docs.rs/anyhow/1.0.40/src/anyhow/fmt.rs.html#19), and even sometimes [`custom error enums`](https://www.lpalmieri.com/posts/error-handling-rust/#error_chain_fmt) use their `Debug` output to print the full chain of errors in a human readable report.
124124

125125
This has the advantage of making it easy to print a full error report and makes it so `unwrap`, `expect`, and return from main all print the full error report. But doing so prevents us from accessing the derived `Debug` format of our errors, potentially hiding internal details that might be needed for debugging but which aren't part of the error messages intended for users to read.
126126

0 commit comments

Comments
 (0)