in sdk/typespec/typespec_client_core/src/error/http_error.rs [128:178]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
struct Status(StatusCode);
impl fmt::Debug for Status {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_fmt(format_args!(
"{} ({})",
std::convert::Into::<u16>::into(self.0),
self.0.canonical_reason()
))
}
}
// Elide potential PII since it's too easily to accidentally leak through Debug or Display.
let mut dbg = f.debug_struct("HttpError");
#[cfg_attr(not(feature = "test"), allow(unused_mut))]
let mut dbg = dbg
.field("Status", &Status(self.status))
.field(
"Error Code",
&Unquote(
self.details
.code
.as_deref()
.unwrap_or("(error code unavailable)"),
),
)
.field(
"Message",
&Unquote(
self.details
.message
.as_deref()
.unwrap_or("(message unavailable)"),
),
);
#[cfg(feature = "test")]
{
dbg = dbg.field(
"Body",
&Unquote(
String::from_utf8(self.body.to_vec())
.as_deref()
.unwrap_or("(bytes)"),
),
);
}
dbg.finish_non_exhaustive()
}