From 66c211f50e8cc4d9566d7d2fa705efd83f73155e Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 15 May 2021 20:40:17 +0100 Subject: [PATCH] otter: Further improve error printing Signed-off-by: Ian Jackson --- src/bin/otter.rs | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) 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); }) } -- 2.30.2