New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
net/http: http.nothingWrittenError incompatible with errors.Is/As #42020
Comments
It seems like implementing /cc @neild I'd be happy to do this change if others agree. |
I don't see a problem in principle, but I wonder if we should be returning https://go.googlesource.com/go/+/refs/heads/master/src/net/http/transport.go#605 I haven't traced all the code pathways, so I'm not sure if adding a case for |
If it makes a difference: nothing written is an information we would be happy to expose to our users. We are currently thinking about using "net/http/httptrace" for that though, so I guess nothing gets lost if you never return |
This still occures with |
Friendly ping about this issue. Do we have an idea which direction we want to go wrt unwrapping |
This has been fixed recently, see: #56451 |
I agree, 531ba0c should fix this and went live with Go 1.20. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
I think so, yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
net/http.Client
net/http.nothingWrittenError
(write tcp 172.31.16.237:54422->1.2.3.4:80: write: connection reset by peer
)var opError *net.OpError; if errors.As(err, &opsError) { ... }
to map to a user friendly errorcodehttp.nothingWrittenError
.What did you expect to see?
I expected
errors.As()
to return true for this errorWhat did you see instead?
I saw
errors.As()
returning false.I believe the problem to occur, since the error is neither the right type nor does
Unwrap()
return theOpError
error at any point (since it is directly inhttp.nothingWrittenError
. The same problem can be observed forerrors.Is()
. See https://play.golang.org/p/0XhEPLe0bRyUse Case
We are running a load test generator written in Go and we need to provide our users with an aggregated error report, thus we need to be able to unpack and understand the errors we receive.
The text was updated successfully, but these errors were encountered: