From e441557ee90e1b93ac1f42ab8904845fd8d6e637 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 7 Jan 2019 22:45:27 +0100 Subject: [PATCH] rpc_util: update deprecated messages (#2545) The status package now has `Convert()` and `Code()` utilities. This patch updates the deprecation description for `ErrorDesc()` and `Code()` to recommend using those functions, and forward the deprecated functions to use the `status.Code()` and `status.Convert()` functions. --- rpc_util.go | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/rpc_util.go b/rpc_util.go index d7cf89f1..8d0d3dc8 100644 --- a/rpc_util.go +++ b/rpc_util.go @@ -685,23 +685,17 @@ func rpcInfoFromContext(ctx context.Context) (s *rpcInfo, ok bool) { // Code returns the error code for err if it was produced by the rpc system. // Otherwise, it returns codes.Unknown. // -// Deprecated: use status.FromError and Code method instead. +// Deprecated: use status.Code instead. func Code(err error) codes.Code { - if s, ok := status.FromError(err); ok { - return s.Code() - } - return codes.Unknown + return status.Code(err) } // ErrorDesc returns the error description of err if it was produced by the rpc system. // Otherwise, it returns err.Error() or empty string when err is nil. // -// Deprecated: use status.FromError and Message method instead. +// Deprecated: use status.Convert and Message method instead. func ErrorDesc(err error) string { - if s, ok := status.FromError(err); ok { - return s.Message() - } - return err.Error() + return status.Convert(err).Message() } // Errorf returns an error containing an error code and a description;