1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
7 import "internal/oserror"
9 // An Errno is an unsigned number describing an error condition.
10 // It implements the error interface. The zero Errno is by convention
11 // a non-error, so code to convert from Errno to error should use:
18 // Errno values can be tested against error values from the os package
19 // using errors.Is. For example:
21 // _, _, err := syscall.Syscall(...)
22 // if errors.Is(err, fs.ErrNotExist) ...
25 func (e Errno
) Error() string {
29 func (e Errno
) Is(target error
) bool {
31 case oserror
.ErrPermission
:
32 return e
== EACCES || e
== EPERM
33 case oserror
.ErrExist
:
34 return e
== EEXIST || e
== ENOTEMPTY
35 case oserror
.ErrNotExist
:
41 func (e Errno
) Temporary() bool {
42 return e
== EINTR || e
== EMFILE || e
== ENFILE || e
.Timeout()
45 func (e Errno
) Timeout() bool {
46 return e
== EAGAIN || e
== EWOULDBLOCK || e
== ETIMEDOUT