Skip to content

Commit

Permalink
Include outer backtrace when called as source.provide
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Sep 4, 2022
1 parent 4b8df91 commit b30f5c5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/error.rs
Expand Up @@ -522,6 +522,17 @@ impl Error {
Some(addr.cast::<E>().deref_mut())
}
}

// Called by thiserror when you have `#[source] anyhow::Error`. This provide
// implementation includes the anyhow::Error's Backtrace if any, unlike
// deref'ing to dyn Error where the provide implementation would include
// only the original error's Backtrace from before it got wrapped into an
// anyhow::Error.
#[cfg(backtrace)]
#[doc(hidden)]
pub fn provide<'a>(&'a self, demand: &mut Demand<'a>) {
unsafe { ErrorImpl::provide(self.inner.by_ref(), demand) }
}
}

#[cfg(feature = "std")]
Expand Down

0 comments on commit b30f5c5

Please sign in to comment.