mirror of
https://github.com/golang/go
synced 2024-11-24 21:00:09 -07:00
net: remove duplicate error information in Dial
R=golang-dev, rsc CC=golang-dev https://golang.org/cl/5293045
This commit is contained in:
parent
48bb3e8f28
commit
565793996c
@ -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
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user