net: expose original context Canceled/DeadlineExceeded error #28529
Labels
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
My apologies if this is already reported however, I haven't been able to find something about in the issue tracker.
What version of Go are you using (
go version
)?Go 1.10.4
Does this issue reproduce with the latest release?
I believe that I would have the same problem in Go 1.11.1 (as far as I can see in the sources of the master branch of this mirror repository)
What operating system and processor architecture are you using (
go env
)?What did you do?
Mostly, if I call net/Dialer.DialContext and the passed context is canceled, I cannot compare the error wrapped by net.OpError (
Err
attribute) with context.Canceled variable in order to distinguish this error of any other.Why?
Because net/Dialer.DialContext calls dialSerial which in case that the
context
is canceled, it replaces thecontext.Canceled
by an unexported error before assigning tonet.OpError.Err
(carried by the unexported function mapErr)The same happens with the
context.DeadlineExceeded
What did you expect to see?
Have the original
context
error in theOpError.Err
attribute.What did you see instead?
What I've described above, but I cannot simply figure it out if the error returned is one of the ones returned by
context
.The text was updated successfully, but these errors were encountered: