#[always_context]Available on crate feature
always-context only.Expand description
Automatically adds .with_context(context!()) to all ? operators that don’t already have context.
Transforms operation()? into operation().with_context(context!("operation()"))?
with function call details, arguments, and file location.
§Requirements
- Function must return
anyhow::Result<T>orResult<T, UserFriendlyError>(please add an issue if you need support for other types)
§Control Attributes
§Macro-level
- Skip
easy_sqlores- Skips requiring context for query! macrosskip_macrosor!- Skips requiring context for macros entirely
Examples: #[always_context(skip(!))], #[always_context(skip(macros, easy_sql))], #[always_context(skip(!, es))]
§Function-level
#[no_context]- Disable context generation entirely#[no_context_inputs]- Add context but exclude function arguments#[enable_context]- Re-enable context (useful in macros where auto-disabled)
§Argument-level
#[context(display)]- UseDisplayinstead ofDebugfor formatting#[context(.method())]- Call method on argument before displaying#[context(tokens)]- Format as token stream (equivalent todisplay+.to_token_stream())#[context(tokens_vec)]- Format as token stream collection#[context(ignore)]or#[context(ignored)]or#[context(no)]- Exclude this argument from context
§Limitations
These expressions before ? require manual .with_context() or .context():
blocks, control flow (if/match/while/for/loop), field access, macros.