| 2083 | } |
| 2084 | |
| 2085 | func (t *myTap) handle(ctx context.Context, info *tap.Info) (context.Context, error) { |
| 2086 | if info != nil { |
| 2087 | switch info.FullMethodName { |
| 2088 | case "/grpc.testing.TestService/EmptyCall": |
| 2089 | t.cnt.Add(1) |
| 2090 | |
| 2091 | if vals := info.Header.Get("return-error"); len(vals) > 0 && vals[0] == "true" { |
| 2092 | return nil, status.Errorf(codes.Unknown, "tap error") |
| 2093 | } |
| 2094 | case "/grpc.testing.TestService/UnaryCall": |
| 2095 | return nil, fmt.Errorf("tap error") |
| 2096 | case "/grpc.testing.TestService/FullDuplexCall": |
| 2097 | return nil, status.Errorf(codes.FailedPrecondition, "test custom error") |
| 2098 | } |
| 2099 | } |
| 2100 | return ctx, nil |
| 2101 | } |
| 2102 | |
| 2103 | func testTap(t *testing.T, e env) { |
| 2104 | te := newTest(t, e) |