mirror of
https://github.com/eyre-rs/eyre.git
synced 2025-09-27 04:50:50 +00:00
provide a default impl for the Display trait
This commit is contained in:
parent
ab76683def
commit
7a9d480c99
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "eyre"
|
||||
version = "0.3.5" # remember to update html_root_url
|
||||
version = "0.3.6" # remember to update html_root_url
|
||||
authors = ["David Tolnay <dtolnay@gmail.com>", "Jane Lusby <jlusby42@gmail.com>"]
|
||||
edition = "2018"
|
||||
license = "MIT OR Apache-2.0"
|
||||
|
@ -58,8 +58,8 @@ eyre = "0.3"
|
||||
## Customization
|
||||
|
||||
In order to insert your own custom context type you must first implement the
|
||||
`eyre::EyreContext` trait for said type, which has three required methods and
|
||||
two optional methods.
|
||||
`eyre::EyreContext` trait for said type, which has two required methods and
|
||||
three optional methods.
|
||||
|
||||
### Required Methods
|
||||
|
||||
@ -80,8 +80,8 @@ fn default(error: &(dyn StdError + 'static)) -> Self {
|
||||
```
|
||||
|
||||
* `fn debug(&self, error: &(dyn Error + 'static), f: &mut fmt::Formatter<'_>)
|
||||
-> fmt Result` and it's companion fn `display`. - For formatting the entire
|
||||
error chain and the user provided context.
|
||||
-> fmt Result` and optionally `display` - For formatting the entire error
|
||||
chain and the user provided context.
|
||||
|
||||
When overriding the context it no longer makes sense for `eyre::ErrReport` to
|
||||
provide the `Display` and `Debug` implementations for the user, becase we
|
||||
|
36
src/lib.rs
36
src/lib.rs
@ -50,8 +50,8 @@
|
||||
//! ## Customization
|
||||
//!
|
||||
//! In order to insert your own custom context type you must first implement the
|
||||
//! `eyre::EyreContext` trait for said type, which has three required methods and
|
||||
//! two optional methods.
|
||||
//! `eyre::EyreContext` trait for said type, which has two required methods and
|
||||
//! three optional methods.
|
||||
//!
|
||||
//! ### Required Methods
|
||||
//!
|
||||
@ -72,7 +72,7 @@
|
||||
//! ```
|
||||
//!
|
||||
//! * `fn debug(&self, error: &(dyn Error + 'static), f: &mut fmt::Formatter<'_>)
|
||||
//! -> fmt Result` and it's companion fn `display`. - For formatting the entire
|
||||
//! -> fmt Result` and optionally `display`. - For formatting the entire
|
||||
//! error chain and the user provided context.
|
||||
//!
|
||||
//! When overriding the context it no longer makes sense for `eyre::ErrReport` to
|
||||
@ -314,7 +314,7 @@
|
||||
//! [`anyhow`]: https://github.com/dtolnay/anyhow
|
||||
//! [`tracing_error::SpanTrace`]: https://docs.rs/tracing-error/*/tracing-error/struct.SpanTrace.html
|
||||
|
||||
#![doc(html_root_url = "https://docs.rs/eyre/0.3.5")]
|
||||
#![doc(html_root_url = "https://docs.rs/eyre/0.3.6")]
|
||||
#![cfg_attr(backtrace, feature(backtrace))]
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
#![allow(
|
||||
@ -485,7 +485,17 @@ pub trait EyreContext: Sized + Send + Sync + 'static {
|
||||
&self,
|
||||
error: &(dyn StdError + 'static),
|
||||
f: &mut core::fmt::Formatter<'_>,
|
||||
) -> core::fmt::Result;
|
||||
) -> core::fmt::Result {
|
||||
write!(f, "{}", error)?;
|
||||
|
||||
if f.alternate() {
|
||||
for cause in crate::chain::Chain::new(error).skip(1) {
|
||||
write!(f, ": {}", cause)?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn debug(
|
||||
&self,
|
||||
@ -514,22 +524,6 @@ impl EyreContext for DefaultContext {
|
||||
}
|
||||
}
|
||||
|
||||
fn display(
|
||||
&self,
|
||||
error: &(dyn StdError + 'static),
|
||||
f: &mut core::fmt::Formatter<'_>,
|
||||
) -> core::fmt::Result {
|
||||
write!(f, "{}", error)?;
|
||||
|
||||
if f.alternate() {
|
||||
for cause in crate::chain::Chain::new(error).skip(1) {
|
||||
write!(f, ": {}", cause)?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn debug(
|
||||
&self,
|
||||
error: &(dyn StdError + 'static),
|
||||
|
Loading…
x
Reference in New Issue
Block a user