Commit 56579399 authored by Andrey Mirtchovski's avatar Andrey Mirtchovski Committed by Russ Cox

net: remove duplicate error information in Dial

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5293045
parent 48bb3e8f
...@@ -59,10 +59,10 @@ func Dial(net, addr string) (c Conn, err os.Error) { ...@@ -59,10 +59,10 @@ func Dial(net, addr string) (c Conn, err os.Error) {
case *IPAddr: case *IPAddr:
c, err = DialIP(net, nil, ra) c, err = DialIP(net, nil, ra)
default: default:
err = UnknownNetworkError(net) err = &OpError{"dial", net + " " + addr, nil, UnknownNetworkError(net)}
} }
if err != nil { if err != nil {
return nil, &OpError{"dial", net + " " + addr, nil, err} return nil, err
} }
return return
} }
......
...@@ -62,6 +62,8 @@ var dialErrorTests = []DialErrorTest{ ...@@ -62,6 +62,8 @@ var dialErrorTests = []DialErrorTest{
}, },
} }
var duplicateErrorPattern = `dial (.*) dial (.*)`
func TestDialError(t *testing.T) { func TestDialError(t *testing.T) {
if !*runErrorTest { if !*runErrorTest {
t.Logf("test disabled; use --run_error_test to enable") t.Logf("test disabled; use --run_error_test to enable")
...@@ -81,6 +83,10 @@ func TestDialError(t *testing.T) { ...@@ -81,6 +83,10 @@ func TestDialError(t *testing.T) {
if !match { if !match {
t.Errorf("#%d: %q, want match for %#q", i, s, tt.Pattern) 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)
}
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment