Wrapper with `thiserror` for inner kind: ```rust use std::panic::Location; use thiserror::Error as ThisError; #[derive(Debug)] struct Error<T> { kind: T, location: &'static Location<'static>, source: Option<Box<dyn std::error::Error>>> } impl<T> Error<T> { #[track_caller] fn new(kind: T) -> Self { Error { kind, location: Location::caller(), source: None } } } impl<T, E> From<E> for Error<T> where T: From<E>, E: std::error::Error, { fn from(value: E) -> Self { Self { kind: value.into(), location: Location::caller(), source: None } } } impl<T: std::fmt::Display> std::fmt::Display for Error<T> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { self.kind.fmt(f) } } #[derive(Debug, ThisError)] enum MainError { #[error("IO error: {0}")] IO(#[from] std::io::Error), } fn main() -> Result<(), Error<MainError>> { for entry in std::fs::read_dir(".")? { let entry = entry?; println!("{}", entry.path().display()); } Ok(()) } ```