Skip to content

Commit

Permalink
fix: Fix concatenation issue in StatusError display (#841)
Browse files Browse the repository at this point in the history
Signed-off-by: Awiteb <[email protected]>
  • Loading branch information
TheAwiteb committed Jul 28, 2024
1 parent 6d4dca5 commit 8184414
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions crates/core/src/http/errors/status_error.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::error::Error as StdError;
use std::fmt::{self, Debug, Display, Formatter};
use std::fmt::{self, Debug, Display, Formatter, Write};

use crate::http::{ResBody, StatusCode};

Expand Down Expand Up @@ -192,12 +192,14 @@ impl StdError for StatusError {}

impl Display for StatusError {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(f, "code: {}", self.code)?;
write!(f, "name: {}", self.name)?;
write!(f, "brief: {:?}", self.brief)?;
write!(f, "detail: {:?}", self.detail)?;
write!(f, "cause: {:?}", self.cause)?;
Ok(())
let mut str_error = format!("code: {} name: {} brief: {}", self.code, self.name, self.brief);
if let Some(detail) = &self.detail {
write!(&mut str_error, " detail: {}", detail)?;
}
if let Some(cause) = &self.cause {
write!(&mut str_error, " cause: {}", cause)?;
}
f.write_str(&str_error)
}
}

Expand Down

0 comments on commit 8184414

Please sign in to comment.