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

Method setGRPCStatus

pkg/errors/grpc.go:69–81  ·  view source on GitHub ↗

setGRPCStatus sets a (marshaled) gRPC status in the error definition. This func should be called when the error definition is created. Doing that makes that we have to convert to a gRPC status only once instead of on every call.

()

Source from the content-addressed store, hash-verified

67// This func should be called when the error definition is created. Doing that
68// makes that we have to convert to a gRPC status only once instead of on every call.
69func (d *Definition) setGRPCStatus() {
70 s := status.New(codes.Code(d.Code()), d.String())
71 if ErrorDetailsToProto != nil {
72 if pb := ErrorDetailsToProto(d); pb != nil {
73 var err error
74 s, err = s.WithDetails(protoadapt.MessageV1Of(pb))
75 if err != nil {
76 panic(err) // ErrorDetailsToProto generated an invalid proto.
77 }
78 }
79 }
80 d.grpcStatus = s
81}
82
83// GRPCStatus returns the Definition as a gRPC status message.
84func (d *Definition) GRPCStatus() *status.Status {

Callers 1

defineFunction · 0.95

Calls 6

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

Tested by

no test coverage detected