Skip to content

client: use error wrapping for WithReturnConnectionError #4822

Open
@anitgandhi

Description

Use case(s) - what problem will this feature solve?

This is essentially a re-open of #4155, because I don't believe it was actually fixed for Dial.

We use grpc.WithBlock on Dial by default in our organization, and we've love to switch to grpc.WithReturnConnectionError instead, but being able to Unwrap to get one of the underlying errors would be nice.

Proposed Solution

Solution #1 as described in #4155.
Basically, use %w instead of %v.

As things stand on the latest release, %v is still used: https://github.com/grpc/grpc-go/blob/v1.41.0/clientconn.go#L227

As of v1.41.0, support for Go <=1.13 has been dropped anyway (#4700 ), so in my opinion it's safe to start using %w going forward.

Alternatives Considered

%w: %w would have been nice, but go vet doesn't allow that, and it also causes errors.Is to return false for both of them, negating the benefits completely.

I'm not sure which one would necessarily be better to use %w on , ctx.Err() or the transport err. But either way, I think it would still be nice to have one of them.

Thanks in advance for considering it!

Metadata

Assignees

No one assigned

    Labels

    Area: ClientIncludes Channel/Subchannel/Streams, Connectivity States, RPC Retries, Dial/Call Options and more.P2Type: FeatureNew features or improvements in behaviorfixit

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions