-
Notifications
You must be signed in to change notification settings - Fork 92
Closed
Description
Hi,
I am porting multiple crates from anyhow to eyre, so I have code that looks something like this:
fn foo() -> Result<(), anyhow::Error> {
Ok(())
}
fn bar() -> Result<(), eyre::Report> {
let f = foo().map_err(|e| eyre::Report::new(e))?;
Ok(())
}This, as expected, gives
error[E0277]: the trait bound `anyhow::Error: std::error::Error` is not satisfied
--> src/lib.rs:6:49
|
6 | let f = foo().map_err(|e| eyre::Report::new(e))?;
| ^ the trait `std::error::Error` is not implemented for `anyhow::Error`
|
::: /home/akshayn/.cargo/registry/src/github.com-1ecc6299db9ec823/eyre-0.6.0/src/error.rs:21:12
|
21 | E: StdError + Send + Sync + 'static,
| -------- required by this bound in `eyre::error::<impl eyre::Report>::new`
error: aborting due to previous error
Since anyhow::Error and eyre::Report are so similar, is there a better way to construct an eyre::Report mid-stack than this, which is sad and throws out the context:
fn foo() -> Result<(), anyhow::Error> {
Ok(())
}
fn bar() -> Result<(), eyre::Report> {
let f = foo().map_err(|e| eyre::eyre!("{:?}", e))?;
Ok(())
}Thanks for the help!
schneiderfelipe and 1298345095
Metadata
Metadata
Assignees
Labels
No labels