src/api_schema/schema.rs: improve ParameterError display function

This commit is contained in:
Dietmar Maurer 2019-02-26 07:11:24 +01:00
parent f661f37427
commit 92a173feb0

View File

@ -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)
}