Skip to content

Commit 7c3f006

Browse files
bobriktottoto
authored andcommitted
feat: Put source error into the Display impl of Status (#2417)
Here's how the error looks before this change: ``` status: 'Some resource has been exhausted', self: "h2 protocol error: http2 error" ``` And here it is after: ``` status: 'Some resource has been exhausted', self: "h2 protocol error: http2 error", source: tonic::transport::Error(Transport, hyper::Error(Http2, Error { kind: GoAway(b"ivan_says_hello", ENHANCE_YOUR_CALM, Remote) })) ``` The latter gives the user a lot more context about the issue. Co-authored-by: tottoto <[email protected]>
1 parent f1456d6 commit 7c3f006

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

tonic/src/status.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,9 @@ impl fmt::Display for Status {
757757
if !self.metadata().is_empty() {
758758
write!(f, ", metadata: {:?}", self.metadata().as_ref())?;
759759
}
760+
if let Some(source) = self.source() {
761+
write!(f, ", source: {source:?}")?;
762+
}
760763
Ok(())
761764
}
762765
}

0 commit comments

Comments
 (0)