Expand description
A simple crate work with thiserror to create errors with contexts, inspired by snafu.
Example
use std::path::{Path, PathBuf};
use thisctx::WithContext;
use thiserror::Error;
#[derive(Debug, Error, WithContext)]
pub enum Error {
#[error("I/O failed '{path}': {source}")]
IoFaild {
source: std::io::Error,
path: PathBuf,
},
}
fn load_config(path: &Path) -> Result<String, Error> {
std::fs::read_to_string(path).context(IoFaildContext { path })
}