use std::io;
use thistrace::{traceable, HasTrace};
#[traceable]
#[derive(thiserror::Error, Debug)]
enum AppError {
#[error("io")]
Io {
#[from]
source: io::Error,
path: std::path::PathBuf,
},
}
fn inner() -> Result<(), io::Error> {
Err(io::Error::new(io::ErrorKind::Other, "boom"))
}
fn outer() -> Result<(), AppError> {
inner()?;
Ok(())
}
#[test]
fn struct_variant_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_from.rs"));
}