From eefb6e5fb6d9a40b04c81a02b78290c6be37440c Mon Sep 17 00:00:00 2001 From: Jeff Date: Thu, 19 Oct 2023 13:52:26 -0400 Subject: [PATCH] Improve error display --- src/error.rs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/error.rs b/src/error.rs index 055b7b6..1fbdab5 100644 --- a/src/error.rs +++ b/src/error.rs @@ -207,10 +207,23 @@ impl fmt::Display for Error { use Error::*; match self { - AssertEqualFailed { expected, actual } => write!( - f, - "Equality assertion failed. {expected} does not equal {actual}." - ), + AssertEqualFailed { expected, actual } => { + write!(f, "Equality assertion failed")?; + + if expected.is_table() { + write!(f, "\n{expected}\n")?; + } else { + write!(f, " {expected} ")?; + } + + write!(f, "does not equal")?; + + if actual.is_table() { + write!(f, "\n{actual}") + } else { + write!(f, " {actual}.") + } + }, AssertFailed => write!( f, "Assertion failed. A false value was passed to \"assert\"."