-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy patherror.go
58 lines (46 loc) · 1.34 KB
/
error.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright (c) 2014, Nick Patavalis ([email protected]).
// All rights reserved.
// Use of this source code is governed by a BSD-style license that can
// be found in the LICENSE.txt file.
// +build linux freebsd netbsd openbsd darwin dragonfly solaris
package poller
type errFlags int
const (
efClosed errFlags = 1 << iota
efTimeout
efTemporary
)
type errT struct {
flags errFlags
msg string
}
func (e *errT) Error() string {
return e.msg
}
func (e *errT) Timeout() bool {
return e.flags&efTimeout != 0
}
func (e *errT) Temporary() bool {
return e.flags&(efTimeout|efTemporary) != 0
}
func (e *errT) Closed() bool {
return e.flags&efClosed != 0
}
func mkErr(flags errFlags, msg string) error {
return &errT{flags: flags, msg: msg}
}
func newErr(msg string) error {
return &errT{msg: msg}
}
// Errors returned by poller functions and methods. In addition to
// these, poller functions and methods may return the errors reported
// by the underlying system calls (open(2), read(2), write(2), etc.),
// as well as io.EOF and io.ErrUnexpectedEOF.
var (
// Use of closed poller file-descriptor. ErrClosed has
// Closed() == true.
ErrClosed error = mkErr(efClosed, "use of closed descriptor")
// Operation timed-out. ErrTimeout has Timeout() == true and
// Temporary() == true.
ErrTimeout error = mkErr(efTimeout, "timeout/deadline expired")
)