Skip to content

Conversation

emilk
Copy link
Contributor

@emilk emilk commented Aug 26, 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)

Copy link
Member

@LucioFranco LucioFranco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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())?;
// }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@LucioFranco LucioFranco merged commit 52f9de8 into hyperium:master Aug 26, 2025
20 checks passed
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)
write!(f, "status: '{}'", self.code())?;

if !self.message().is_empty() {
write!(f, ", self: {:?}", self.message())?;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LucioFranco should this be

Suggested change
write!(f, ", self: {:?}", self.message())?;
write!(f, ", message: {:?}", self.message())?;

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tottoto pushed a commit that referenced this pull request Sep 20, 2025
* Follow-up to #2403

I accidentally used confusing labels. Thanks to @kloakin for pointing it
out.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants