Improve Status formatting#2403
Merged
LucioFranco merged 2 commits intoAug 26, 2025
Merged
Conversation
LucioFranco
requested changes
Aug 26, 2025
Member
LucioFranco
left a comment
There was a problem hiding this comment.
LGTM, one small nit but otherwise I think this is a positive change.
Comment on lines
+756
to
+759
| // Binary data - not useful to human eyes. | ||
| // if !self.details().is_empty() { | ||
| // write!(f, ", details: {:?}", self.details())?; | ||
| // } |
Member
There was a problem hiding this comment.
I think we def want this in debug, display I think is fine to skip so I think we can just remove this whole block?
emilk
commented
Aug 26, 2025
LucioFranco
approved these changes
Aug 26, 2025
xumaple
pushed a commit
to xumaple/tonic
that referenced
this pull request
Aug 29, 2025
## Motivation The `Status` struct is the canonical error message in `tonic`. Printing it currently prints out a very verbose and difficult-to-read message. ## Solution Improve `impl, Display for status` by: * Only printing the `message` if it is non-empty * Only printing the `metadata` if it is non-empty` * Always omitting the binary `details` (printing out `details: [22, 51, 50, 48, 51, 53, 98, 57, 50, 55, 50, 55, 100, 54, 101, …]` is not helping anyone)
This was referenced Sep 16, 2025
kloakin
reviewed
Sep 18, 2025
| write!(f, "status: '{}'", self.code())?; | ||
|
|
||
| if !self.message().is_empty() { | ||
| write!(f, ", self: {:?}", self.message())?; |
There was a problem hiding this comment.
@LucioFranco should this be
Suggested change
| write!(f, ", self: {:?}", self.message())?; | |
| write!(f, ", message: {:?}", self.message())?; |
?
Contributor
Author
There was a problem hiding this comment.
Contributor
|
A follow-up to this: #2417 |
alexanderrilee
pushed a commit
to alexanderrilee/tonic
that referenced
this pull request
Oct 29, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The
Statusstruct is the canonical error message intonic. Printing it currently prints out a very verbose and difficult-to-read message.Solution
Improve
impl, Display for statusby:messageif it is non-emptymetadataif it is non-empty`details(printing outdetails: [22, 51, 50, 48, 51, 53, 98, 57, 50, 55, 50, 55, 100, 54, 101, …]is not helping anyone)