cockroachdb / errors

Go error library with error portability over the network

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Recognizing errors across the network

matterpale opened this issue · comments

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!

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?

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