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:
17 // Errno values can be tested against error values from the os package
18 // using errors.Is. For example:
20 // _, _, err := syscall.Syscall(...)
21 // if errors.Is(err, os.ErrNotExist) ...
24 func (e Errno
) Error() string {
28 func (e Errno
) Is(target error
) bool {
30 case oserror
.ErrPermission
:
31 return e
== EACCES || e
== EPERM
32 case oserror
.ErrExist
:
33 return e
== EEXIST || e
== ENOTEMPTY
34 case oserror
.ErrNotExist
:
40 func (e Errno
) Temporary() bool {
41 return e
== EINTR || e
== EMFILE || e
== ENFILE || e
.Timeout()
44 func (e Errno
) Timeout() bool {
45 return e
== EAGAIN || e
== EWOULDBLOCK || e
== ETIMEDOUT