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::Fail; #[derive(Fail, Display, Debug)] pub enum RootError { #[display(fmt = "RootError: {}", message)] RootError { message: String }, } #[derive(Fail, Display, Debug)] pub enum TopError { #[display(fmt = "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 errors = process_errors!(chain); assert_eq!(errors, "TopError: top, RootError: root"); let errors = process_errors!(chain, '\n'); assert_eq!(errors, "TopError: top\nRootError: root"); }