wrapIfLikelyWithGRPCNotUsedError adds a wrapping error that has a message telling the caller that they likely forgot to use connect.WithGRPC(). This happens when running a gRPC-only server. This is fragile and may break over time, and this should be considered a best-effort.
(err error)
| 364 | // This happens when running a gRPC-only server. |
| 365 | // This is fragile and may break over time, and this should be considered a best-effort. |
| 366 | func wrapIfLikelyWithGRPCNotUsedError(err error) error { |
| 367 | if err == nil { |
| 368 | return nil |
| 369 | } |
| 370 | if _, ok := asError(err); ok { |
| 371 | return err |
| 372 | } |
| 373 | // golang.org/x/net code has been investigated and there is no typing of this error |
| 374 | // it is created with fmt.Errorf |
| 375 | // http2/transport.go:573: return nil, fmt.Errorf("http2: Transport: cannot retry err [%v] after Request.Body was written; define Request.GetBody to avoid this error", err) |
| 376 | if errString := err.Error(); strings.HasPrefix(errString, `Post "`) && |
| 377 | strings.Contains(errString, `http2: Transport: cannot retry err`) && |
| 378 | strings.HasSuffix(errString, `after Request.Body was written; define Request.GetBody to avoid this error`) { |
| 379 | return fmt.Errorf("possible missing connect.WithGPRC() client option when talking to gRPC server, see %s: %w", commonErrorsURL, err) |
| 380 | } |
| 381 | return err |
| 382 | } |
| 383 | |
| 384 | // HTTP/2 has its own set of error codes, which it sends in RST_STREAM frames. |
| 385 | // When the server sends one of these errors, we should map it back into our |
no test coverage detected