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ZBRYETJFUZ6RK5BPUC3TGDDZPQC
D3BYK6HTL2CTGGNM7ZKAGIDFPWV4OF4FFYDRCPADNC7OGFSYN65QC
RIKD63GT7RFV3UAV4BYD57GFXKXALWUP6J7AAHB3M6JVAZ3WFTXAC
W655S25G7CGI4XOZ2PKITKTH26VJ4QMZFRV2RPYNI4KIUJOIGVMAC
GZZOJ7ZUSBPI3HXIV5UCFNMCDAMZPPLISY2UDV73FDN74HZ3AWJAC
CZP5PD5NYLDULLW43VOL6V75CH6DDEJO7H6JSGQSIV2WNSQF4A6QC
3ZZ75E2AOF7DO3TMR422QV7ZXNYOQZTOGF67LVSCEMX6N75Y36LAC
B35ATKRQB7JRNWXZD2YRYT6H73ZTQBUEXHZWZCHQEIOMSST5QJ6QC
YNTEYSW7NVBWQLJU45XRK7AWQR5NWFOB4UUVVQ62ERZOO2QJJGAAC
F5MLEQJFOB443KKN22TYYJN2TR52653MD4VXSEYZQBNWWJYES5VQC
AEVUCD3O343GYQLS7EO5ULPGVTGXSOXDKU3RVENI3ZJ3MFYTZ2ZAC
T64LKJ2RTUDFYSJQI7KF4WHZYXZHNEGNOS7ZMMCRIQZ4YN5LOOMAC
DFDCD3LPJCYCNINXBXGFAYD4CT2SBI4RBITE7OK5D5QPTIWWMQKAC
3YMIGCYC3YUOZP5OBNSTOIJOT6ZTEDDKNMR5YCAJRD5JNBYFETYAC
OQCFKTKCBTWGXL27ZLWQSL4L5VPREJAYN7MVCCR4GXW6WLWYOUHAC
VSLQNAQBAGOJC2IV55V3W755UIPN47J4RTCCLCABRFFFUU5LT2JQC
N7U2FHPRHGARPZ6M7LYBDJ52NMYE23VD5YALZ7CC76W3V5OLBP7QC
BZSTVYDVHJA3ZMCM3YTU4U5JKJC2JVUDM5APSBIGMSS54J2C4WKQC
W2HZHFIDFNDKTZ4CIRTZH6XWWV7KHHRROORVUCDNJQKEDQGUMK4QC
/// Get the backtrace for this Report.
///
/// Backtraces are only available on the nightly channel. Tracking issue:
/// [rust-lang/rust#53487][tracking].
///
/// In order for the backtrace to be meaningful, one of the two environment
/// variables `RUST_LIB_BACKTRACE=1` or `RUST_BACKTRACE=1` must be defined
/// and `RUST_LIB_BACKTRACE` must not be `0`. Backtraces are somewhat
/// expensive to capture in Rust, so we don't necessarily want to be
/// capturing them all over the place all the time.
///
/// - If you want panics and errors to both have backtraces, set
/// `RUST_BACKTRACE=1`;
/// - If you want only errors to have backtraces, set
/// `RUST_LIB_BACKTRACE=1`;
/// - If you want only panics to have backtraces, set `RUST_BACKTRACE=1` and
/// `RUST_LIB_BACKTRACE=0`.
///
/// [tracking]: https://github.com/rust-lang/rust/issues/53487
#[cfg(backtrace)]
pub fn backtrace(&self) -> &Backtrace {
self.inner.backtrace()
}
}
pub fn member_ref<T: Any>(&self) -> Option<&T> {
self.context
.as_ref()
.unwrap()
.member_ref(TypeId::of::<T>())?
.downcast_ref::<T>()
}
pub fn member_mut<T: Any>(&mut self) -> Option<&mut T> {
self.context
.as_mut()
.unwrap()
.member_mut(TypeId::of::<T>())?
.downcast_mut::<T>()
#[cfg(backtrace)]
pub(crate) fn backtrace(&self) -> &Backtrace {
// This unwrap can only panic if the underlying error's backtrace method
// is nondeterministic, which would only happen in maliciously
// constructed code.
self.member_ref()
.or_else(|| self.error().backtrace())
.expect("backtrace capture failed")
}
/// Member access function
///
/// The main reason to implement this fn is to provide support for `eyre::Report::backtrace`
/// which will call this fn on `nightly` when attempting access the captured
/// `std::backtrace::Backtrace`
///
/// # Example
fn member_ref(&self, _typeid: TypeId) -> Option<&dyn Any> {
None
}
#[doc(hidden)]
fn member_mut(&mut self, _typeid: TypeId) -> Option<&mut dyn Any> {
None
}
#[doc(hidden)]
/// Override for the `Display` format
fn member_ref(&self, typeid: TypeId) -> Option<&dyn Any> {
if typeid == TypeId::of::<Backtrace>() {
self.backtrace.as_ref().map(|b| b as &dyn Any)
} else {
None
}
}
#[rustversion::not(nightly)]
#[ignore]
#[test]
fn test_backtrace() {}
#[rustversion::nightly]
#[test]
fn test_backtrace() {
use eyre::{eyre, Report};
let error: Report = eyre!("oh no!");
let _ = error.backtrace();
}
#[test]
fn test_context() {
use eyre::{eyre, Report};
let error: Report = eyre!("oh no!");
let _ = error.context();
}