diff --git a/src/pkg/net/dial.go b/src/pkg/net/dial.go index 10c67dcc40a..85d54b3703c 100644 --- a/src/pkg/net/dial.go +++ b/src/pkg/net/dial.go @@ -59,10 +59,10 @@ func Dial(net, addr string) (c Conn, err os.Error) { case *IPAddr: c, err = DialIP(net, nil, ra) default: - err = UnknownNetworkError(net) + err = &OpError{"dial", net + " " + addr, nil, UnknownNetworkError(net)} } if err != nil { - return nil, &OpError{"dial", net + " " + addr, nil, err} + return nil, err } return } diff --git a/src/pkg/net/net_test.go b/src/pkg/net/net_test.go index e4d7a253e20..3754bc90b33 100644 --- a/src/pkg/net/net_test.go +++ b/src/pkg/net/net_test.go @@ -62,6 +62,8 @@ var dialErrorTests = []DialErrorTest{ }, } +var duplicateErrorPattern = `dial (.*) dial (.*)` + func TestDialError(t *testing.T) { if !*runErrorTest { t.Logf("test disabled; use --run_error_test to enable") @@ -81,6 +83,10 @@ func TestDialError(t *testing.T) { if !match { t.Errorf("#%d: %q, want match for %#q", i, s, tt.Pattern) } + match, _ = regexp.MatchString(duplicateErrorPattern, s) + if match { + t.Errorf("#%d: %q, duplicate error return from Dial", i, s) + } } }