FromGRPCStatus converts the gRPC status message into an Error.
(grpcStatus *status.Status)
| 26 | |
| 27 | // FromGRPCStatus converts the gRPC status message into an Error. |
| 28 | func FromGRPCStatus(grpcStatus *status.Status) *Error { |
| 29 | err := build(&Definition{ |
| 30 | code: uint32(grpcStatus.Code()), |
| 31 | messageFormat: grpcStatus.Message(), |
| 32 | }, 0) |
| 33 | if ErrorDetailsFromProto == nil { |
| 34 | return err |
| 35 | } |
| 36 | detailMsgs := grpcStatus.Details() |
| 37 | detailProtos := make([]proto.Message, 0, len(detailMsgs)) |
| 38 | for _, msg := range detailMsgs { // convert to []proto.Message |
| 39 | if msg, ok := msg.(proto.Message); ok { |
| 40 | detailProtos = append(detailProtos, msg) |
| 41 | } |
| 42 | } |
| 43 | details, rest := ErrorDetailsFromProto(detailProtos...) |
| 44 | if len(rest) != 0 { |
| 45 | err.details = rest |
| 46 | } |
| 47 | if details != nil { |
| 48 | setErrorDetails(err, details) |
| 49 | } |
| 50 | return err |
| 51 | } |
| 52 | |
| 53 | // ErrorDetailsToProto converts the given ErrorDetails into a protobuf-encoded message. |
| 54 | // |