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

stats.End.Error does not implement status.Status #1416

Closed
grantr opened this issue Aug 3, 2017 · 2 comments · Fixed by #1418
Closed

stats.End.Error does not implement status.Status #1416

grantr opened this issue Aug 3, 2017 · 2 comments · Fixed by #1418

Comments

@grantr
Copy link

grantr commented Aug 3, 2017

Please answer these questions before submitting your issue.

What version of gRPC are you using?

1.5.1

What version of Go are you using (go version)?

go1.8.1 darwin/amd64

What operating system (Linux, Windows, …) and version?

MacOS 10.12.5

What did you do?

The stats documentation at

// Error is the error just happened. It implements status.Status if non-nil.
states:

Error is the error just happened. It implements status.Status if non-nil.

Since the type of Error is error, I tried casting it to status.Status like this:

if sts, ok := event.Error.(status.Status); ok {
  // do stuff with sts
}

What did you expect to see?

I expected to be able to cast the error to a status.Status and call Code() on it 😄

What did you see instead?

this error from the compiler:

impossible type assertion:
	".../google.golang.org/grpc/status".Status does not implement error (missing Error method)
@menghanl
Copy link
Contributor

menghanl commented Aug 3, 2017

It implements status.Status is not accurate.
It should be something like It is an error generated from status.Status and can be converted back to status.Status.
status.FromError should work for this error.
Sorry for the confusion. This should be fixed in #1418.

@grantr
Copy link
Author

grantr commented Aug 3, 2017

Thanks @menghani! This now compiles:

if sts, ok := status.FromError(event.Error); ok {
  //do stuff with sts
}

@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
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants