From: Ian Jackson Date: Sat, 15 May 2021 19:40:17 +0000 (+0100) Subject: otter: Further improve error printing X-Git-Tag: otter-0.6.0~261 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=66c211f50e8cc4d9566d7d2fa705efd83f73155e;p=otter.git otter: Further improve error printing Signed-off-by: Ian Jackson --- diff --git a/src/bin/otter.rs b/src/bin/otter.rs index 75016025..45480347 100644 --- a/src/bin/otter.rs +++ b/src/bin/otter.rs @@ -436,11 +436,27 @@ fn main() { &subcommand)); call(sc, mo, subargs).unwrap_or_else(|e|{ - eprint!("otter: error"); + #[derive(Default,Debug)] struct Sol { any: bool } + impl Sol { + fn nl(&mut self) { + if self.any { eprintln!("") }; + self.any = false; + } + fn head(&mut self) { + if ! self.any { eprint!("otter: error"); } + self.any = true + } + } + let mut sol: Sol = default(); for e in e.chain() { - eprint!(": {}", &e); + let s = e.to_string(); + let long = s.len() > 80; + if long && sol.any { sol.nl() } + sol.head(); + eprint!(": {}", s); + if long { sol.nl() } } - eprintln!(""); + sol.nl(); exit(12); }) }