macro_rules! process_errors {
    ($err:ident) => { ... };
    ($err:ident, $delim:expr) => { ... };
}
Expand description

Iterate through a failure::Error and concatenate the error and all its causes into a single string

Examples

use kubos_service::process_errors;
use failure::{Error, Fail};

#[derive(Clone, Debug, Fail)]
pub enum RootError {
    #[fail(display = "RootError: {}", message)]
    RootError { message: String },
}

#[derive(Clone, Debug, Fail)]
pub enum TopError {
    #[fail(display = "TopError: {}", message)]
    Error {
        #[fail(cause)]
        cause: RootError,
        message: String,
    },
}

let chain: TopError = TopError::Error {
    cause: RootError::RootError { message: "root".to_owned() },
    message: "top".to_owned(),
};

let chain_clone = chain.clone();

let errors = process_errors!(chain);
assert_eq!(errors, "TopError: top, RootError: root");

let errors = process_errors!(chain_clone, '\n');
assert_eq!(errors, "TopError: top\nRootError: root");