Expand description
thistrace adds callsite provenance (file/line/column) to thiserror enums
without requiring map_err(...) at each callsite.
It works by generating #[track_caller] From<T> impls for #[from] conversions,
so ? captures the location where the conversion happened.
§Quickstart
use thistrace::prelude::*;
#[traceable]
#[derive(Debug, thiserror::Error)]
enum AppError {
#[error("io")]
Io(#[from] Origin<std::io::Error>),
}
fn leaf() -> Result<(), Origin<std::io::Error>> {
Err(origin(std::io::Error::new(std::io::ErrorKind::Other, "boom")))
}
fn top() -> Result<(), AppError> {
leaf()?; // adds a conversion/bubble frame
Ok(())
}
let err = top().unwrap_err();
let _ = format!("{}", OneLineTrace::new(&err));
assert!(!trace_frames(&err).is_empty());