forked from proxmox-mirrors/proxmox
schema: beautify parameter error output
If there is only one error, output in a single line, without any excessive newlines at the end. If there are multiple errors, show them in a bulleted list. Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
This commit is contained in:
parent
34e86078c2
commit
c1c062bf56
@ -101,14 +101,18 @@ impl fmt::Display for ParameterError {
|
|||||||
let mut msg = String::new();
|
let mut msg = String::new();
|
||||||
|
|
||||||
if !self.is_empty() {
|
if !self.is_empty() {
|
||||||
msg.push_str("parameter verification errors\n\n");
|
if self.len() == 1 {
|
||||||
|
msg.push_str("parameter verification failed - ");
|
||||||
|
let _ = write!(msg, "'{}': {}", self.error_list[0].0, self.error_list[0].1);
|
||||||
|
} else {
|
||||||
|
msg.push_str("parameter verification failed:\n");
|
||||||
|
for (name, err) in self.error_list.iter() {
|
||||||
|
let _ = writeln!(msg, "- '{}': {}", name, err);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (name, err) in self.error_list.iter() {
|
write!(f, "{}", msg.trim())
|
||||||
let _ = writeln!(msg, "parameter '{}': {}", name, err);
|
|
||||||
}
|
|
||||||
|
|
||||||
write!(f, "{}", msg)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user