#[error_strategy]Expand description
The error_strategy attribute macro
This macro transforms a function that returns Result<T, E> into one that
returns PipexResult<T, E>, allowing the pipex library to apply the specified
error handling strategy. Works with both sync and async functions.
§Arguments
strategy- The error handling strategy type (e.g.,IgnoreHandler,CollectHandler)
§Examples
ⓘ
use pipex_macros::error_strategy;
// Async function
#[error_strategy(IgnoreHandler)]
async fn process_item_async(x: i32) -> Result<i32, String> {
if x % 2 == 0 {
Ok(x * 2)
} else {
Err("Odd number".to_string())
}
}
// Sync function
#[error_strategy(CollectHandler)]
fn process_item_sync(x: i32) -> Result<i32, String> {
if x % 2 == 0 {
Ok(x * 2)
} else {
Err("Odd number".to_string())
}
}The generated function will automatically wrap the result in a PipexResult
with the specified strategy name, allowing the pipeline to handle errors
according to the strategy.