Attribute Macro err_context

Source
#[err_context]
Expand description

Add a context when this function returns an error.

This macro takes a single argument: the error kind which serves as context. This macro is compatible with both sync and async functions. The function must return a Result<T, Error> for some T, where Error is an error type generated by the declare_error_type macro.

#[err_context(ErrorKind::Parse)]
fn parse(s: &str) -> Result<SomeStruct, Error> {
    // ...
}