From a1d09806c815e76a6349706a5ce1de75ce1f0816 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 1 Jun 2021 01:26:15 +0100 Subject: [PATCH] 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 --- src/utils.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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); -- 2.30.2