thistrace 0.1.0

Callsite provenance (file/line/col) for thiserror #[from] conversions via #[track_caller]
Documentation
use std::io;

use thistrace::{traceable, HasTrace};

#[traceable]
#[derive(thiserror::Error, Debug)]
enum AppError {
    #[error("io")]
    Io {
        #[from]
        source: io::Error,
    },
}

fn inner() -> Result<(), io::Error> {
    Err(io::Error::new(io::ErrorKind::Other, "boom"))
}

fn outer() -> Result<(), AppError> {
    inner()?;
    Ok(())
}

#[test]
fn struct_variant_simple_from_captures_frame() {
    let err = outer().unwrap_err();
    let trace = err.trace().expect("trace should exist");
    assert_eq!(trace.frames().len(), 1);
    assert!(trace.frames()[0].file.ends_with("struct_variant_simple.rs"));
}