(frame: Frame)
| 295 | |
| 296 | #[track_caller] |
| 297 | pub(crate) fn from_frame(frame: Frame) -> Self { |
| 298 | #[cfg(nightly)] |
| 299 | let location = core::error::request_ref::<Location>(&frame.as_error()) |
| 300 | .is_none() |
| 301 | .then_some(Location::caller()); |
| 302 | |
| 303 | #[cfg(not(nightly))] |
| 304 | let location = Some(Location::caller()); |
| 305 | |
| 306 | #[cfg(all(nightly, feature = "backtrace"))] |
| 307 | let backtrace = core::error::request_ref::<Backtrace>(&frame.as_error()) |
| 308 | .is_none_or(|backtrace| backtrace.status() != BacktraceStatus::Captured) |
| 309 | .then(Backtrace::capture); |
| 310 | |
| 311 | #[cfg(all(not(nightly), feature = "backtrace"))] |
| 312 | let backtrace = Some(Backtrace::capture()); |
| 313 | |
| 314 | #[cfg(all(nightly, feature = "spantrace"))] |
| 315 | let span_trace = core::error::request_ref::<SpanTrace>(&frame.as_error()) |
| 316 | .is_none_or(|span_trace| span_trace.status() != SpanTraceStatus::CAPTURED) |
| 317 | .then(SpanTrace::capture); |
| 318 | |
| 319 | #[cfg(all(not(nightly), feature = "spantrace"))] |
| 320 | let span_trace = Some(SpanTrace::capture()); |
| 321 | |
| 322 | let mut report = Self { |
| 323 | frames: Box::new(vec![frame]), |
| 324 | _context: PhantomData, |
| 325 | }; |
| 326 | |
| 327 | if let Some(location) = location { |
| 328 | report = report.attach_opaque(*location); |
| 329 | } |
| 330 | |
| 331 | #[cfg(feature = "backtrace")] |
| 332 | if let Some(backtrace) = |
| 333 | backtrace.filter(|bt| matches!(bt.status(), BacktraceStatus::Captured)) |
| 334 | { |
| 335 | report = report.attach_opaque(backtrace); |
| 336 | } |
| 337 | |
| 338 | #[cfg(feature = "spantrace")] |
| 339 | if let Some(span_trace) = span_trace.filter(|st| st.status() == SpanTraceStatus::CAPTURED) { |
| 340 | report = report.attach_opaque(span_trace); |
| 341 | } |
| 342 | |
| 343 | report |
| 344 | } |
| 345 | |
| 346 | /// Converts a `Report` with a single context into a `Report` with multiple contexts. |
| 347 | /// |
nothing calls this directly
no test coverage detected