MCPcopy Index your code
hub / github.com/cockroachdb/errors / IsNotExist

Function IsNotExist

oserror/oserror.go:90–106  ·  view source on GitHub ↗

IsNotExist returns a boolean indicating whether the error is known to report that a file or directory does not exist. It is satisfied by ErrNotExist as well as some syscall errors. This function differs from os.IsNotExist() in that it can identify an error through wrapping layers.

(err error)

Source from the content-addressed store, hash-verified

88// This function differs from os.IsNotExist() in that it
89// can identify an error through wrapping layers.
90func IsNotExist(err error) bool {
91 // errors.Is() is not able to peek through os.SyscallError,
92 // whereas os.IsNotExist() can. Conversely, os.IsNotExist()
93 // cannot peek through Unwrap, whereas errors.Is() can. So we
94 // need to try both.
95 if errors.Is(err, ErrNotExist) || os.IsNotExist(errors.UnwrapAll(err)) {
96 return true
97 }
98 // If a syscall errno representing ErrNotExist was encoded on a
99 // different platform, and decoded here, then it will show up as
100 // neither a syscall errno here nor an ErrNotExist; instead it
101 // shows up as an OpaqueErrno. We test this here.
102 if o := (*errbase.OpaqueErrno)(nil); errors.As(err, &o) {
103 return o.Is(ErrNotExist)
104 }
105 return false
106}
107
108// IsTimeout returns a boolean indicating whether the error is known
109// to report that a timeout occurred.

Callers 3

TestAdaptErrnoFunction · 0.92
TestErrorPredicatesUnixFunction · 0.85
TestErrorPredicatesFunction · 0.85

Calls 4

IsFunction · 0.92
UnwrapAllFunction · 0.92
AsFunction · 0.92
IsMethod · 0.45

Tested by 3

TestAdaptErrnoFunction · 0.74
TestErrorPredicatesUnixFunction · 0.68
TestErrorPredicatesFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…