From dd6466b151b8807cc5498ed628e78df74c55dd88 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Tue, 28 May 2024 08:11:01 -0400 Subject: [PATCH] refactor: improve fmt::Debug for legacy::Error (#99) --- src/client/legacy/client.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/client/legacy/client.rs b/src/client/legacy/client.rs index c638db6..6ed7c0f 100644 --- a/src/client/legacy/client.rs +++ b/src/client/legacy/client.rs @@ -52,7 +52,6 @@ struct Config { } /// Client errors -#[derive(Debug)] pub struct Error { kind: ErrorKind, source: Option>, @@ -1566,6 +1565,17 @@ impl fmt::Debug for Builder { // ==== impl Error ==== +impl fmt::Debug for Error { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let mut f = f.debug_tuple("hyper_util::client::legacy::Error"); + f.field(&self.kind); + if let Some(ref cause) = self.cause { + f.field(cause); + } + f.finish() + } +} + impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "client error ({:?})", self.kind)