error-stack-derive 0.1.0

A derive macro to use in pair with error_stack or generally any error system
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
use error_stack_derive::ErrorStack;

#[derive(ErrorStack, Debug)]
#[error_message(&format!("An exception occured with foo: {}", self.0))]

struct FooError(String);
fn main() -> Result<(), FooError> {
    let contents = std::fs::read_to_string("foo.txt").map_err(|e| FooError(e.to_string()))?;

    println!("{contents}");

    Ok(())
}