From 92a173feb01b4fcff8c7c717a43be94bccfadacf Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Tue, 26 Feb 2019 07:11:24 +0100 Subject: [PATCH] src/api_schema/schema.rs: improve ParameterError display function --- src/api_schema/schema.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/api_schema/schema.rs b/src/api_schema/schema.rs index fbe2c839..8f1c3a9d 100644 --- a/src/api_schema/schema.rs +++ b/src/api_schema/schema.rs @@ -36,9 +36,16 @@ impl ParameterError { impl fmt::Display for ParameterError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let msg = self.error_list.iter().fold(String::from(""), |acc, item| { + + let mut msg = String::new(); + + if self.len() > 0 { + msg.push_str("parameter verification errors\n\n"); + } + + msg.push_str(&self.error_list.iter().fold(String::from(""), |acc, item| { acc + &item.to_string() + "\n" - }); + })); write!(f, "{}", msg) }