net/http: push roundTrip panic higher in the stack

If Transport is a non-nil interface pointing to a nil implementer,
then a panic inside of roundTrip further obsfucates the issue.

Change-Id: I47664b8e6185c5f56b5e529f49022484b5ea1d94
Reviewed-on: https://go-review.googlesource.com/c/go/+/661897
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Neal Patel <nealpatel@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
This commit is contained in:
Neal Patel 2025-04-01 17:04:29 -04:00 committed by Gopher Robot
parent ec4a9fb321
commit 53badd4836

View File

@ -27,5 +27,8 @@ func badRoundTrip(*Transport, *Request) (*Response, error)
// Like the RoundTripper interface, the error types returned
// by RoundTrip are unspecified.
func (t *Transport) RoundTrip(req *Request) (*Response, error) {
if t == nil {
panic("transport is nil")
}
return t.roundTrip(req)
}