-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Improve Status
formatting
#2403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve Status
formatting
#2403
Conversation
There was a problem hiding this 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.
tonic/src/status.rs
Outdated
// Binary data - not useful to human eyes. | ||
// if !self.details().is_empty() { | ||
// write!(f, ", details: {:?}", self.details())?; | ||
// } |
There was a problem hiding this comment.
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?
## 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())?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LucioFranco should this be
write!(f, ", self: {:?}", self.message())?; | |
write!(f, ", message: {:?}", self.message())?; |
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Motivation
The
Status
struct is the canonical error message intonic
. Printing it currently prints out a very verbose and difficult-to-read message.Solution
Improve
impl, Display for status
by:message
if it is non-emptymetadata
if 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)