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

Implement the errors.Unwrap interface as appropriate #4567

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions internal/status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions internal/transport/http2_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 5 additions & 0 deletions internal/transport/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down