Macro kubos_service::process_errors [−][src]
macro_rules! process_errors { ($err:ident) => { ... }; ($err:ident, $delim:expr) => { ... }; }
Iterate through a failure::Error and concatenate the error and all its causes into a single string
Examples
#[macro_use] extern crate failure; use failure::Error; #[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, }, } fn main() { 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"); }