-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tutorial for how to use EyreContext #8
Conversation
//! ```rust | ||
//! fn default(_: &(dyn std::error::Error + 'static)) -> Self { | ||
//! Self | ||
//! } | ||
//! ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth including the impl EyreContext
block here, so it's clear where in the code this default
method should be placed.
I intuited that this was supposed to be a Default::default
, but it's not.
//! * Start with defining an empty context that captures nothing | ||
//! * Add support for capturing backtraces | ||
//! * skip backtrace capture if our source captured one | ||
//! * Add support for a http status codes | ||
//! * Implement a setter for Result<T, Report> with a new Trait |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be nice to have anchor links here for the TOC, to jump to the relevant sections.
//! And next we need to implement `debug` to tell eyre how to format the final report including | ||
//! your custom context: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd be good to clarify why this method is called "debug", and how it differs from fmt::Debug
, perhaps with an intra-doc link to the documentation on the EyreContext
trait.
//! Things to note, we're using some utilities provided by `eyre` for writing error reports, | ||
//! | ||
//! - `Chain`: iterator for errors while the `chain` fn on the error trait is still unstable. | ||
//! - `Indenter`: a wrapper for formatters that inserts indentation after newlines for handling | ||
//! multi line error messages nicely |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit of an awkward place to mention the crates being used. I think it could perhaps be nice to mention them off-hand at the beginning, and have more detailed information in an appendix-type thing?
//! | ||
//! # Introduction | ||
//! | ||
//! In this tutorial we will go through the process of implementing a custom context step by step: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd be really valuable to have a section before you begin implementing a custom context explaining what a custom context is, and why you might want one. It doesn't necessarily have to be here, but a sentence mentioning where in the docs you can learn the motivation would be nice.
//! // ... | ||
//! } | ||
//! ``` | ||
//! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think including some example code here which reads the status from an error as well would be awesome!
//! if f.alternate() { | ||
//! return core::fmt::Debug::fmt(error, f); | ||
//! } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be good to mention documentation which explains why alternate
is being checked here.
No description provided.