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

Method GRPCStatus

pkg/errors/grpc.go:96–112  ·  view source on GitHub ↗

GRPCStatus converts the Error into a gRPC status message.

()

Source from the content-addressed store, hash-verified

94
95// GRPCStatus converts the Error into a gRPC status message.
96func (e *Error) GRPCStatus() *status.Status {
97 if s, ok := e.grpcStatus.Load().(*status.Status); ok && s != nil {
98 return s
99 }
100 s := status.New(codes.Code(e.Code()), e.String())
101 if ErrorDetailsToProto != nil {
102 if pb := ErrorDetailsToProto(e); pb != nil {
103 var err error
104 s, err = s.WithDetails(protoadapt.MessageV1Of(pb))
105 if err != nil {
106 panic(err) // ErrorDetailsToProto generated an invalid proto.
107 }
108 }
109 }
110 e.grpcStatus.Store(s)
111 return s
112}
113
114// UnaryServerInterceptor makes sure that returned TTN errors contain a CorrelationID.
115func UnaryServerInterceptor() grpc.UnaryServerInterceptor {

Callers 8

MarshalJSONMethod · 0.95
TestCodesFunction · 0.45
TestGRPCConversionFunction · 0.45
TestResemblesFunction · 0.45
FromFunction · 0.45
TestDetailsFunction · 0.45
TestHTTPFunction · 0.45
TestGRPCConversionFunction · 0.45

Calls 7

CodeMethod · 0.95
StringMethod · 0.95
WithDetailsMethod · 0.95
ErrorDetailsToProtoFunction · 0.85
NewMethod · 0.65
CodeMethod · 0.65
LoadMethod · 0.45

Tested by 6

TestCodesFunction · 0.36
TestGRPCConversionFunction · 0.36
TestResemblesFunction · 0.36
TestDetailsFunction · 0.36
TestHTTPFunction · 0.36
TestGRPCConversionFunction · 0.36