From: Ian Jackson Date: Tue, 1 Jun 2021 00:26:15 +0000 (+0100) Subject: utils: error end_process: Do not print duplicate messages X-Git-Tag: otter-0.7.0~172 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=a1d09806c815e76a6349706a5ce1de75ce1f0816;p=otter.git utils: error end_process: Do not print duplicate messages Sometimes we use thiserror to put {0} of an inner error in our Display impl. If that happens, just skip the repetition. This is a slight bodge. Signed-off-by: Ian Jackson --- diff --git a/src/utils.rs b/src/utils.rs index 0daef636..9c73675a 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -659,13 +659,16 @@ impl anyhow::Error { } } let mut sol: Sol = default(); + let mut printed = String::new(); for e in self.chain() { let s = e.to_string(); + if printed.contains(&s) { continue } let long = s.len() > 80; if long && sol.any { sol.nl() } sol.head(); - eprint!(": {}", s); + eprint!(": {}", &s); if long { sol.nl() } + printed = s; } sol.nl(); assert!(estatus > 0);