You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#![feature(backtrace)]
use anyhow;
use thiserror::Error;
#[derive(Error, Debug)]
enum Gus {
#[error("hmm")]
Other(
#[from]
#[backtrace]
anyhow::Error,
),
}
fn main() {
use std::error::Error;
use std::ops::Deref;
println!("{:?}", Gus::from(anyhow::anyhow!("main")));
println!("{:?}", Gus::from(anyhow::anyhow!("main")).backtrace());
println!("{:?}", anyhow::anyhow!("main").deref().backtrace());
}
results in
>printing the error with a backtrace
None
None
Looking briefly at the code, this appears to be at least semi-on-purpose, where the vtable for adhoc errors points to no_backtrace, but it links the backtrace back in somehow? can the ErrorImpl coercion do the same things as
(also, is there a reason the backtrace is only printed for the Debug impl, not the Display impl, should the docs be updated to reflect that?)
The text was updated successfully, but these errors were encountered:
guswynn
changed the title
anyhow's dyn error bactrace disagrees with
anyhow's dyn error bactrace disagrees with anyhow::Error::backtraceMar 25, 2022
guswynn
changed the title
anyhow's dyn error bactrace disagrees with anyhow::Error::backtrace
anyhow's dyn error bacltrace disagrees with anyhow::Error::backtraceMar 25, 2022
guswynn
changed the title
anyhow's dyn error bacltrace disagrees with anyhow::Error::backtrace
anyhow's dyn error backtrace disagrees with anyhow::Error::backtraceMar 25, 2022
The last one is still None because you've written .deref() which specifically dereferences to the underlying Error impl that the anyhow::Error was constructed from, but the thiserror-generated Error impl has the correct backtrace now. It may be possible to do it for .deref() too but since your issue involves thiserror it doesn't sound like your issue was motivated by that case.
results in
Looking briefly at the code, this appears to be at least semi-on-purpose, where the vtable for adhoc errors points to
no_backtrace
, but it links the backtrace back in somehow? can theErrorImpl
coercion do the same things asanyhow/src/error.rs
Line 880 in 6833150
(also, is there a reason the backtrace is only printed for the
Debug
impl, not theDisplay
impl, should the docs be updated to reflect that?)The text was updated successfully, but these errors were encountered: