diff --git a/src/main.rs b/src/main.rs index 21fc69c..9ae6187 100644 --- a/src/main.rs +++ b/src/main.rs @@ -132,7 +132,8 @@ fn process_instructions( let out = match tera.render(&i.template, &ctx) { Ok(o) => o, Err(e) => { - error!("Failed to render template {}: {}", i.template, e); + let msg = format_error(&e); + error!("Failed to render template {}: {}", i.template, msg); continue; } }; @@ -229,3 +230,13 @@ fn chmod( info!("Set mode of {} to {:o}", path.as_ref().display(), newmode); Ok(()) } + +fn format_error(e: &dyn std::error::Error) -> String { + // TODO replace this with std::error::Error::sources when it is stablized. + // https://github.com/rust-lang/rust/issues/58520 + let mut msg = e.to_string(); + if let Some(e) = e.source() { + msg.push_str(&format!(": {}", format_error(e))); + } + msg +}