🛈 Note: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem.

For the release documentation, please see docs.rs, instead.

pub trait ExtractSpanTrace {
    // Required method
    fn span_trace(&self) -> Option<&SpanTrace>;
}
Expand description

A trait for extracting SpanTraces created by in_current_span() from dyn Error trait objects

Required Methods§

source

fn span_trace(&self) -> Option<&SpanTrace>

Attempts to downcast to a TracedError and return a reference to its SpanTrace

§Examples
use tracing_error::ExtractSpanTrace;
use std::error::Error;

fn print_span_trace(e: &(dyn Error + 'static)) {
    let span_trace = e.span_trace();
    if let Some(span_trace) = span_trace {
        println!("{}", span_trace);
    }
}

Implementations on Foreign Types§

source§

impl ExtractSpanTrace for dyn Error + 'static

source§

fn span_trace(&self) -> Option<&SpanTrace>

Available on crate feature traced-error only.

Implementors§