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)
| 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. |
| 138 | func 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. |
no test coverage detected
searching dependent graphs…