cockroachdb / errors

Go error library with error portability over the network
Apache License 2.0
2.04k stars 66 forks source link

Recognizing errors across the network #108

Closed matterpale closed 1 year ago

matterpale commented 1 year ago

One of the features listed in the table in readme reads:

errors.Is() recognizes errors across the network

The way I understand that is, once both the gRPC server and client have access to a shared package within which some sentinel errors are defined, the client can use the errors.Is() function to match the errors returned from gRPC calls and build logic around that.

However, that does not seem to work (see here). Perhaps I misunderstood or overlooked some crucial step? In any case, a working example or at least a little more detail on this funtionality would help a lot, thank you!

knz commented 1 year ago

gRPC doesn't use cockroachdb/errors by default. you need to opt into this handling manually. See this package and the examples therein: https://github.com/cockroachdb/errors/tree/master/grpc

Does this help?

matterpale commented 1 year ago

Oh dear, I skipped the interceptors, my bad. Thank you!