From 776bf411236579c394d4e1024d5edf53808a312f Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Wed, 30 Jan 2019 20:42:53 +0100 Subject: [PATCH] Show actual Tera source error --- components/errors/src/lib.rs | 12 +++++++++++- src/console.rs | 3 ++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/components/errors/src/lib.rs b/components/errors/src/lib.rs index 5c2c2dab..c8ada64b 100755 --- a/components/errors/src/lib.rs +++ b/components/errors/src/lib.rs @@ -29,7 +29,17 @@ unsafe impl Send for Error {} impl StdError for Error { fn source(&self) -> Option<&(dyn StdError + 'static)> { - self.source.as_ref().map(|c| &**c) + let mut source = self.source.as_ref().map(|c| &**c); + if source.is_none() { + match self.kind { + ErrorKind::Tera(ref err) => { + source = err.source() + }, + _ => () + }; + } + + source } } diff --git a/src/console.rs b/src/console.rs index 5151cf82..719f3ad4 100644 --- a/src/console.rs +++ b/src/console.rs @@ -8,6 +8,7 @@ use chrono::Duration; use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor}; use site::Site; +use errors::Error; lazy_static! { /// Termcolor color choice. @@ -92,7 +93,7 @@ pub fn report_elapsed_time(instant: Instant) { } /// Display an error message and the actual error(s) -pub fn unravel_errors(message: &str, error: &StdError) { +pub fn unravel_errors(message: &str, error: &Error) { if !message.is_empty() { self::error(message); }