Skip to main content

error_chain_with

Function error_chain_with 

pub fn error_chain_with<'a, F>(
    error: &'a (dyn Error + 'static),
    next_source: F,
) -> impl Iterator<Item = &'a (dyn Error + 'static)>
where F: FnMut(&'a (dyn Error + 'static)) -> Option<&'a (dyn Error + 'static)>,
Expand description

Iterate over an error and custom successors, visiting at most 64 errors.

The next_source callback selects one successor per error, replacing Error::source traversal. Return None to end the chain, or explicitly call Error::source in the callback when it should provide the fallback successor.

The callback runs only when another item is requested within the limit and stops once the chain ends. The iterator does not allocate or deduplicate errors. Use error_chain_with_limit_and to choose another traversal bound.