Skip to main content

error_chain

Function error_chain 

pub fn error_chain<'a>(
    error: &'a (dyn Error + 'static),
    max_depth: usize,
) -> impl Iterator<Item = &'a (dyn Error + 'static)>
Expand description

Iterate over an error and its sources, visiting at most max_depth errors.

The supplied error is the first item and counts toward the limit. A zero limit yields no items. The limit bounds cyclic as well as long source chains; repeated errors are not deduplicated. This iterator does not allocate.

Sources are requested only when advancing past the current error, so an early match does not inspect that error’s source. Only Error::source is followed; use error_chain_with for errors that expose causes through another API.