Skip to content

Commit a2a3514

Browse files
committed
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
1 parent 3f5288c commit a2a3514

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/pkg/net/net.go

+10-5
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,16 @@ type Listener interface {
275275
Addr() Addr
276276
}
277277

278-
var errMissingAddress = errors.New("missing address")
278+
// Various errors contained in OpError.
279+
var (
280+
// For connection setup and write operations.
281+
errMissingAddress = errors.New("missing address")
282+
283+
// For both read and write operations.
284+
errTimeout error = &timeoutError{}
285+
errClosing = errors.New("use of closed network connection")
286+
ErrWriteToConnected = errors.New("use of WriteTo with pre-connected connection")
287+
)
279288

280289
// OpError is the error type usually returned by functions in the net
281290
// package. It describes the operation, network type, and address of
@@ -337,10 +346,6 @@ func (e *timeoutError) Error() string { return "i/o timeout" }
337346
func (e *timeoutError) Timeout() bool { return true }
338347
func (e *timeoutError) Temporary() bool { return true }
339348

340-
var errTimeout error = &timeoutError{}
341-
342-
var errClosing = errors.New("use of closed network connection")
343-
344349
type AddrError struct {
345350
Err string
346351
Addr string

src/pkg/net/udpsock.go

-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44

55
package net
66

7-
import "errors"
8-
9-
var ErrWriteToConnected = errors.New("use of WriteTo with pre-connected UDP")
10-
117
// UDPAddr represents the address of a UDP end point.
128
type UDPAddr struct {
139
IP IP

0 commit comments

Comments
 (0)