MCPcopy Create free account
hub / github.com/cockroachdb/errors / encodeGrpcStatus

Function encodeGrpcStatus

extgrpc/ext_grpc.go:138–148  ·  view source on GitHub ↗

encodeGrpcStatus takes an error generated by a standard gRPC Status and converts it into a GoGo Protobuf representation from github.com/gogo/googleapis/google/rpc. This is necessary since EncodedError uses an Any field for structured errors, and thus can only contain Protobufs that have been regist

(_ context.Context, err error)

Source from the content-addressed store, hash-verified

136// Status, and all details must be gogoproto types. The reasons for this
137// are the same as for the Any field issue mentioned above.
138func encodeGrpcStatus(_ context.Context, err error) (string, []string, proto.Message) {
139 s := gogostatus.Convert(err)
140 // If there are known safe details, return them.
141 details := []string{}
142 for _, detail := range s.Details() {
143 if safe, ok := detail.(errbase.SafeDetailer); ok {
144 details = append(details, safe.SafeDetails()...)
145 }
146 }
147 return s.Message(), details, s.Proto()
148}
149
150// decodeGrpcStatus is the inverse of encodeGrpcStatus. It takes a gogoproto
151// Status as input, and converts it into a standard gRPC Status error.

Callers 1

encodeGoGoStatusFunction · 0.85

Calls 3

DetailsMethod · 0.80
MessageMethod · 0.80
SafeDetailsMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…