diff options
| author | Mikio Hara <mikioh.mikioh@gmail.com> | 2014-04-08 06:14:49 +0900 |
|---|---|---|
| committer | Mikio Hara <mikioh.mikioh@gmail.com> | 2014-04-08 06:14:49 +0900 |
| commit | a2a351478bb223891ebe8c1ae09c6ad09648f138 (patch) | |
| tree | cebb4f51d3a36d9822eb738b66ca287d8d613ad8 /src/pkg | |
| parent | 3f5288cb0845a8e9d5c3e6ec73141876d4179f9e (diff) | |
| download | go-a2a351478bb223891ebe8c1ae09c6ad09648f138.tar.xz | |
net: move error messages related to OpError into net.go
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
Diffstat (limited to 'src/pkg')
| -rw-r--r-- | src/pkg/net/net.go | 15 | ||||
| -rw-r--r-- | src/pkg/net/udpsock.go | 4 |
2 files changed, 10 insertions, 9 deletions
diff --git a/src/pkg/net/net.go b/src/pkg/net/net.go index 2e6db55514..ca56af54fc 100644 --- a/src/pkg/net/net.go +++ b/src/pkg/net/net.go @@ -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 diff --git a/src/pkg/net/udpsock.go b/src/pkg/net/udpsock.go index 0dd0dbd711..4c99ae4af6 100644 --- a/src/pkg/net/udpsock.go +++ b/src/pkg/net/udpsock.go @@ -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 |
