...
1 package sys
2
3 import "strconv"
4
5
6
7
8
9
10 type Errno uint16
11
12
13
14
15
16
17
18
19
20
21
22
23 const (
24 EACCES Errno = iota + 1
25 EAGAIN
26 EBADF
27 EEXIST
28 EFAULT
29 EINTR
30 EINVAL
31 EIO
32 EISDIR
33 ELOOP
34 ENAMETOOLONG
35 ENOENT
36 ENOSYS
37 ENOTDIR
38 ERANGE
39 ENOTEMPTY
40 ENOTSOCK
41 ENOTSUP
42 EPERM
43 EROFS
44
45
46
47
48 )
49
50
51 func (e Errno) Error() string {
52 switch e {
53 case 0:
54 return "success"
55 case EACCES:
56 return "permission denied"
57 case EAGAIN:
58 return "resource unavailable, try again"
59 case EBADF:
60 return "bad file descriptor"
61 case EEXIST:
62 return "file exists"
63 case EFAULT:
64 return "bad address"
65 case EINTR:
66 return "interrupted function"
67 case EINVAL:
68 return "invalid argument"
69 case EIO:
70 return "input/output error"
71 case EISDIR:
72 return "is a directory"
73 case ELOOP:
74 return "too many levels of symbolic links"
75 case ENAMETOOLONG:
76 return "filename too long"
77 case ENOENT:
78 return "no such file or directory"
79 case ENOSYS:
80 return "functionality not supported"
81 case ENOTDIR:
82 return "not a directory or a symbolic link to a directory"
83 case ERANGE:
84 return "result too large"
85 case ENOTEMPTY:
86 return "directory not empty"
87 case ENOTSOCK:
88 return "not a socket"
89 case ENOTSUP:
90 return "not supported (may be the same value as [EOPNOTSUPP])"
91 case EPERM:
92 return "operation not permitted"
93 case EROFS:
94 return "read-only file system"
95 default:
96 return "Errno(" + strconv.Itoa(int(e)) + ")"
97 }
98 }
99
View as plain text