MCPcopy Index your code
hub / github.com/cockroachdb/errors / GetGrpcCode

Function GetGrpcCode

extgrpc/ext_grpc.go:72–85  ·  view source on GitHub ↗

GetGrpcCode retrieves the gRPC code from a stack of causes.

(err error)

Source from the content-addressed store, hash-verified

70
71// GetGrpcCode retrieves the gRPC code from a stack of causes.
72func GetGrpcCode(err error) codes.Code {
73 if err == nil {
74 return codes.OK
75 }
76 if v, ok := markers.If(err, func(err error) (interface{}, bool) {
77 if w, ok := err.(*withGrpcCode); ok {
78 return w.code, true
79 }
80 return nil, false
81 }); ok {
82 return v.(codes.Code)
83 }
84 return codes.Unknown
85}
86
87// it's an error.
88func (w *withGrpcCode) Error() string { return w.cause.Error() }

Callers 3

UnaryServerInterceptorFunction · 0.92
CodeFunction · 0.92
TestGrpcFunction · 0.92

Calls 1

IfFunction · 0.92

Tested by 1

TestGrpcFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…