StreamServerInterceptor makes sure that returned TTN errors contain a CorrelationID.
()
| 126 | |
| 127 | // StreamServerInterceptor makes sure that returned TTN errors contain a CorrelationID. |
| 128 | func StreamServerInterceptor() grpc.StreamServerInterceptor { |
| 129 | return func( |
| 130 | srv any, stream grpc.ServerStream, _ *grpc.StreamServerInfo, handler grpc.StreamHandler, |
| 131 | ) error { |
| 132 | err := handler(srv, stream) |
| 133 | if ttnErr, ok := From(err); ok { |
| 134 | err = ttnErr |
| 135 | } |
| 136 | return err |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | // UnaryClientInterceptor converts gRPC errors to regular errors. |
| 141 | func UnaryClientInterceptor() grpc.UnaryClientInterceptor { |