Skip to content

Commit

Permalink
refactor: improve fmt::Debug for legacy::Error (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmonstar committed May 28, 2024
1 parent 8f29948 commit dd6466b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/client/legacy/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ struct Config {
}

/// Client errors
#[derive(Debug)]
pub struct Error {
kind: ErrorKind,
source: Option<Box<dyn StdError + Send + Sync>>,
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit dd6466b

Please sign in to comment.