forked from Sandertv/go-raknet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
err.go
33 lines (30 loc) · 954 Bytes
/
err.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package raknet
import (
"errors"
"net"
)
var (
// ErrBufferTooSmall is returned when Conn.Read is called with a byte slice
// that is too small to contain the packet to be read.
ErrBufferTooSmall = errors.New("a message sent was larger than the buffer used to receive the message into")
// ErrListenerClosed is returned when Listener.Accept is called on a closed
// listener.
ErrListenerClosed = errors.New("use of closed listener")
// ErrNotSupported is returned for deadline methods of a Conn, which are not
// supported on a raknet.Conn.
ErrNotSupported = errors.New("feature not supported")
)
// error wraps the error passed into a net.OpError with the op as operation and
// returns it, or nil if the error passed is nil.
func (conn *Conn) error(err error, op string) error {
if err == nil {
return nil
}
return &net.OpError{
Op: op,
Net: "raknet",
Source: conn.LocalAddr(),
Addr: conn.raddr,
Err: err,
}
}