-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy patherrors.go
44 lines (36 loc) · 1.15 KB
/
errors.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
package hackpadfs
import (
"io/fs"
"syscall"
)
// Errors commonly returned by file systems. Mirror their equivalents in the syscall and io/fs packages.
var (
ErrInvalid = syscall.EINVAL // TODO update to fs.ErrInvalid, once errors.Is supports it
ErrPermission = fs.ErrPermission
ErrExist = fs.ErrExist
ErrNotExist = fs.ErrNotExist
ErrClosed = fs.ErrClosed
ErrIsDir = syscall.EISDIR
ErrNotDir = syscall.ENOTDIR
ErrNotEmpty = syscall.ENOTEMPTY
ErrNotImplemented = syscall.ENOSYS
SkipDir = fs.SkipDir
)
// PathError records a file system or file operation error and the path that caused it. Mirrors io/fs.PathError
type PathError = fs.PathError
// LinkError records a file system rename error and the paths that caused it. Mirrors os.LinkError
//
// NOTE: Is not identical to os.LinkError to avoid importing "os". Still resolves errors.Is() calls correctly.
type LinkError struct {
Err error
Op string
Old string
New string
}
func (e *LinkError) Error() string {
return e.Op + " " + e.Old + " " + e.New + ": " + e.Err.Error()
}
// Unwrap supports errors.Unwrap().
func (e *LinkError) Unwrap() error {
return e.Err
}