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

Function UnaryServerInterceptor

pkg/errors/grpc.go:115–125  ·  view source on GitHub ↗

UnaryServerInterceptor makes sure that returned TTN errors contain a CorrelationID.

()

Source from the content-addressed store, hash-verified

113
114// UnaryServerInterceptor makes sure that returned TTN errors contain a CorrelationID.
115func UnaryServerInterceptor() grpc.UnaryServerInterceptor {
116 return func(
117 ctx context.Context, req any, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler,
118 ) (any, error) {
119 res, err := handler(ctx, req)
120 if ttnErr, ok := From(err); ok {
121 err = ttnErr
122 }
123 return res, err
124 }
125}
126
127// StreamServerInterceptor makes sure that returned TTN errors contain a CorrelationID.
128func StreamServerInterceptor() grpc.StreamServerInterceptor {

Callers 2

NewFunction · 0.92
TestHooksFunction · 0.92

Calls 2

handlerFunction · 0.85
FromFunction · 0.85

Tested by 1

TestHooksFunction · 0.74