[][src]Attribute Macro fn_error_context::context

#[context]

Add context to errors from a function.

The arguments to this macro are a format string with arguments using the standard std::fmt syntax. Arguments to the function can be used as long as they are not consumed in the function body.

This macro desugars to something like

pub fn function() -> anyhow::Result<()> {
    (|| -> anyhow::Result<()> {
        function_body()
    })().map_err(|err| err.context("context"))
}