Skip to content
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

Go - Write sample code for setting and reading error details #478

Closed
jcanizales opened this issue Dec 19, 2015 · 7 comments
Closed

Go - Write sample code for setting and reading error details #478

jcanizales opened this issue Dec 19, 2015 · 7 comments
Labels
P3 Type: Documentation Documentation or examples

Comments

@jcanizales
Copy link

Go issue for grpc/grpc#4543

@jcanizales jcanizales added the Type: Documentation Documentation or examples label Dec 19, 2015
@kelseyhightower
Copy link

Is this something I can take a shot at? I've been playing with grpc and wonder if the following example would work:

Creating a grpc error:
https://github.com/kelseyhightower/grpc-hello-service/blob/master/hello-server/main.go#L74

@jcanizales
Copy link
Author

You're very very welcome to give it a shot!

More specifically, we'd want a sample that shows sending an error with metadata attached in the HTTP/2 trailers, as well as reading that metadata from the client. That being the recommended way to specify error details when the error code isn't enough to make the error actionable.

@kelseyhightower
Copy link

Fixed in #506. @jcanizales PTAL

@c4milo
Copy link
Contributor

c4milo commented Jul 19, 2017

@dfawley, shouldn't this be closed since it seems addressed by #506?

@dfawley
Copy link
Member

dfawley commented Jul 19, 2017

That PR was not merged.. A different sample is necessary with the recentish changes to status.

(And now with the helpers added in #1358.)

@dfawley dfawley added the P3 label Dec 14, 2017
@enocom
Copy link
Contributor

enocom commented Mar 10, 2018

In #506, the APIs on display were grpc.SetTrailer on the server, and grpc.Trailer on the client.

With the helpers added in #1358, it seems the preferred way to transfer error details is status.WithDetails on the server and status.Details on the client.

Is that the gist of the issue here?

@dfawley
Copy link
Member

dfawley commented Mar 12, 2018

@enocom,

Is that the gist of the issue here?

Correct! Trailers are still useful. However, for detailed error information, status.WithDetails should be used instead. (Trailers can be used to transmit additional data at the end of an RPC even on success.)

@lock lock bot locked as resolved and limited conversation to collaborators Sep 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P3 Type: Documentation Documentation or examples
Projects
None yet
Development

No branches or pull requests

6 participants