MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / FromGRPCStatus

Function FromGRPCStatus

pkg/errors/grpc.go:28–51  ·  view source on GitHub ↗

FromGRPCStatus converts the gRPC status message into an Error.

(grpcStatus *status.Status)

Source from the content-addressed store, hash-verified

26
27// FromGRPCStatus converts the gRPC status message into an Error.
28func 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//

Callers 5

TestGRPCConversionFunction · 0.92
TestHTTPFunction · 0.92
TestGRPCConversionFunction · 0.92
FromFunction · 0.85
UnmarshalJSONMethod · 0.85

Calls 6

buildFunction · 0.85
ErrorDetailsFromProtoFunction · 0.85
setErrorDetailsFunction · 0.85
CodeMethod · 0.65
MessageMethod · 0.65
DetailsMethod · 0.65

Tested by 3

TestGRPCConversionFunction · 0.74
TestHTTPFunction · 0.74
TestGRPCConversionFunction · 0.74