Replace deprecated grpc functions#2645
Conversation
b5430b6 to
78191a8
Compare
78191a8 to
2776dca
Compare
Codecov Report
@@ Coverage Diff @@
## master #2645 +/- ##
=========================================
Coverage ? 61.83%
=========================================
Files ? 134
Lines ? 21772
Branches ? 0
=========================================
Hits ? 13463
Misses ? 6863
Partials ? 1446 |
|
@cyli @anshulpundir I fixed the linting issue; this is green now PTAL |
| func main() { | ||
| if c, err := mainCmd.ExecuteC(); err != nil { | ||
| c.Println("Error:", grpc.ErrorDesc(err)) | ||
| msg := err.Error() |
There was a problem hiding this comment.
Non-blocking: This works fine, but from the GRPC docstring for status.FromError:
FromError returns a
Statusrepresenting err if it was produced from this package or has a methodGRPCStatus() *Status. Otherwise, ok is false and a Status is returned with codes.Unknown and the original error message.
So it sounds like you can probably just do:
s, _ := status.FromError(err)
c.Println(s.Message())| // Handle errors. | ||
| if grpc.Code(err) == codes.NotFound && grpc.ErrorDesc(err) == membership.ErrMemberRemoved.Error() { | ||
| s, _ = status.FromError(err) | ||
| if s.Code() == codes.NotFound && testutils.ErrorDesc(err) == membership.ErrMemberRemoved.Error() { |
There was a problem hiding this comment.
We should probably not be importing testutils from non-test code. Can we just call s.Message()?
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2776dca to
cb6dcf2
Compare
|
@cyli thanks for reviewing! I rebased, and addressed your comments; PTAL |
cyli
left a comment
There was a problem hiding this comment.
LGTM - thanks for staying on top of the GRPC changes @thaJeztah!
grpc.ErrorDesc(err)andgrpc.Code(err)were deprecated in favor of the "status" package in grpc/grpc-go@b507112Replacing these with their equivalent, in case the deprecated methods are removed in future