Skip to main content

error_source

Function error_source 

pub fn error_source<'a>(
    error: &'a (dyn Error + 'static),
) -> Option<&'a (dyn Error + 'static)>
Expand description

The error that comes after error in its chain.

This is Error::source, except for a std::io::Error (with the std feature): its source reports the source of the error it wraps, skipping that error, so this returns the wrapped error itself instead.

Use it as the fallback successor of an error_chain_with callback.

use rama_error::{BoxError, BoxErrorExt, error_source};

let io = std::io::Error::other(BoxError::from_static_str("inner"));
let next = error_source(&io).expect("the wrapped error");
assert_eq!(next.to_string(), "inner");