-
Notifications
You must be signed in to change notification settings - Fork 14
/
errors.go
38 lines (30 loc) · 870 Bytes
/
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
package storage
import (
"errors"
"fmt"
)
var ErrNotImplemented = errors.New("not implemented")
// isNotExister is an interface used to define the behaviour of errors resulting
// from operations which report missing files/paths.
type isNotExister interface {
isNotExist() bool
}
// IsNotExist returns a boolean indicating whether the error is known to report that
// a path does not exist.
func IsNotExist(err error) bool {
var e isNotExister
if err != nil && errors.As(err, &e) {
return e.isNotExist()
}
return false
}
// notExistError is returned from FS.Open implementations when a requested
// path does not exist.
type notExistError struct {
Path string
}
func (e *notExistError) isNotExist() bool { return true }
// Error implements error
func (e *notExistError) Error() string {
return fmt.Sprintf("storage %v: path does not exist", e.Path)
}