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
14
15
16
17
use error_stack::{IntoReport, Result, ResultExt};
use error_stack_derive::ErrorStack;

#[derive(ErrorStack, Debug)]
#[error_message("An exception occured with foo")]
struct FooError;

fn main() -> Result<(), FooError> {
    let contents = std::fs::read_to_string("foo.txt")
        .report()
        .change_context(FooError)
        .attach_printable("Unable to read foo.txt file")?;

    println!("{contents}");

    Ok(())
}