]> Cypherpunks repositories - gostls13.git/commitdiff
net: move error messages related to OpError into net.go
authorMikio Hara <mikioh.mikioh@gmail.com>
Mon, 7 Apr 2014 21:14:49 +0000 (06:14 +0900)
committerMikio Hara <mikioh.mikioh@gmail.com>
Mon, 7 Apr 2014 21:14:49 +0000 (06:14 +0900)
Also makes ErrWriteToConnected more appropriate; it's used
not only UDPConn operations but UnixConn operations.

Update #4856

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/84800044

src/pkg/net/net.go
src/pkg/net/udpsock.go

index 2e6db5551430cb55e0d07da6706e6f8b1153013c..ca56af54fc6f899c4510934e7a3cb76177eecab5 100644 (file)
@@ -275,7 +275,16 @@ type Listener interface {
        Addr() Addr
 }
 
-var errMissingAddress = errors.New("missing address")
+// Various errors contained in OpError.
+var (
+       // For connection setup and write operations.
+       errMissingAddress = errors.New("missing address")
+
+       // For both read and write operations.
+       errTimeout          error = &timeoutError{}
+       errClosing                = errors.New("use of closed network connection")
+       ErrWriteToConnected       = errors.New("use of WriteTo with pre-connected connection")
+)
 
 // OpError is the error type usually returned by functions in the net
 // package. It describes the operation, network type, and address of
@@ -337,10 +346,6 @@ func (e *timeoutError) Error() string   { return "i/o timeout" }
 func (e *timeoutError) Timeout() bool   { return true }
 func (e *timeoutError) Temporary() bool { return true }
 
-var errTimeout error = &timeoutError{}
-
-var errClosing = errors.New("use of closed network connection")
-
 type AddrError struct {
        Err  string
        Addr string
index 0dd0dbd711444b6a07cc26c9916be58df88845d3..4c99ae4af6837e8c01ae03dcec0ca2111b2f0ac2 100644 (file)
@@ -4,10 +4,6 @@
 
 package net
 
-import "errors"
-
-var ErrWriteToConnected = errors.New("use of WriteTo with pre-connected UDP")
-
 // UDPAddr represents the address of a UDP end point.
 type UDPAddr struct {
        IP   IP