-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Send Unix errors without wrapping them or casting them.
While trying to import MountedFast into k8s to detect mount points using openat2, several tests failed because they rely on os.IsErrNotExist / os.IsPermission which do not actually test the underlying error. For a non-existent path, if we return the bare error, this problem is solved. I tested for the following cases to ensure that backward compatibility is not broken: fmt.Println(os.IsNotExist(err)) returns false fmt.Println(os.IsNotExist(&os.PathError{ Op: "lstat", Path: "somepath", Err: err, })) returns false fmt.Println(os.IsNotExist(fmt.Errorf("unable: %w", err))) returns false fmt.Println(errors.Is(fmt.Errorf("unable: %w", err), os.ErrNotExist)) returns true.
- Loading branch information
Showing
2 changed files
with
7 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters