MCPcopy Create free account
hub / github.com/hashintel/hash / anyhow_backtrace

Function anyhow_backtrace

libs/error-stack/tests/test_compatibility.rs:78–99  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

76#[test]
77#[cfg(all(nightly, feature = "backtrace", feature = "anyhow"))]
78fn anyhow_backtrace() {
79 let error = anyhow::anyhow!("test error");
80 let error_backtrace = error.backtrace();
81 let error_backtrace_len = error_backtrace.frames().len();
82 #[cfg(not(miri))]
83 let error_backtrace_string = error_backtrace.to_string();
84
85 let report: Report<anyhow::Error> = Err::<(), _>(error)
86 .into_report()
87 .expect_err("should have returned error");
88 let report_backtrace = report
89 .request_ref::<std::backtrace::Backtrace>()
90 .next()
91 .expect("No backtrace captured");
92 let report_backtrace_len = report_backtrace.frames().len();
93 #[cfg(not(miri))]
94 let report_backtrace_string = report_backtrace.to_string();
95
96 assert_eq!(error_backtrace_len, report_backtrace_len);
97 #[cfg(not(miri))]
98 assert_eq!(error_backtrace_string, report_backtrace_string);
99}
100
101#[test]
102#[cfg(feature = "anyhow")]

Callers

nothing calls this directly

Calls 6

backtraceMethod · 0.80
framesMethod · 0.80
lenMethod · 0.45
into_reportMethod · 0.45
expectMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected