From c1fb398e16563a5e4382c973755e894fe09a7678 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 26 Jun 2021 12:16:53 -0600 Subject: [PATCH 1/2] status.Error.Is: Update/fix the doc comment - The comment speaks of "future error.Is functionality"; well Go 1.13 has since been released; it isn't "future" anymore. Change "future" to "Go 1.13". - In that same phrase, change "error.Is" to "errors.Is"; since it's referring to the functionality in the "errors" package. - The second sentence starts "A Error"; change that to "An Error". --- internal/status/status.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/status/status.go b/internal/status/status.go index 710223b8ded0..4ac86ae8fc6d 100644 --- a/internal/status/status.go +++ b/internal/status/status.go @@ -151,8 +151,8 @@ func (e *Error) GRPCStatus() *Status { return FromProto(e.e) } -// Is implements future error.Is functionality. -// A Error is equivalent if the code and message are identical. +// Is implements Go 1.13 errors.Is functionality. +// An Error is equivalent if the code and message are identical. func (e *Error) Is(target error) bool { tse, ok := target.(*Error) if !ok { From 5ef87f395316822c1a4858b79cbc59c1ebbbe01a Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 26 Jun 2021 12:26:44 -0600 Subject: [PATCH 2/2] Implement errors.Unwrap as appropriate There are several implementations of `error` that happen to wrap an inner `error`. Have these also implement the standard interface for `errors.Unwrap`. --- internal/transport/http2_client.go | 5 +++++ internal/transport/transport.go | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/internal/transport/http2_client.go b/internal/transport/http2_client.go index 48c5e52edae9..ba1e1ba5b83e 100644 --- a/internal/transport/http2_client.go +++ b/internal/transport/http2_client.go @@ -619,6 +619,11 @@ func (p PerformedIOError) Error() string { return p.Err.Error() } +// Unwrap implements Go 1.13 errors.Unwrap functionality. +func (p PerformedIOError) Unwrap() error { + return p.Err +} + // NewStream creates a stream and registers it into the transport as "active" // streams. func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (_ *Stream, err error) { diff --git a/internal/transport/transport.go b/internal/transport/transport.go index 6cc1031fd92f..630bdb8e7d03 100644 --- a/internal/transport/transport.go +++ b/internal/transport/transport.go @@ -735,6 +735,11 @@ func (e ConnectionError) Temporary() bool { return e.temp } +// Unwrap implements Go 1.13 errors.Unwrap functionality. +func (e ConnectionError) Unwrap() error { + return e.err +} + // Origin returns the original error of this connection error. func (e ConnectionError) Origin() error { // Never return nil error here.