Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return false if nil is passed to IsNotExistError #2616

Merged
merged 2 commits into from
Aug 27, 2024

Conversation

PlasmaPower
Copy link
Collaborator

This matches behavior with errors.Is

@cla-bot cla-bot bot added the s Automatically added by the CLA bot if the creator of a PR is registered as having signed the CLA. label Aug 27, 2024
}

func isLeveldbNotExistError(err error) bool {
return os.IsNotExist(err)
return errors.Is(err, fs.ErrNotExist)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is from the os.IsNotExist docs:

// IsNotExist returns a boolean indicating whether its argument 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 predates [errors.Is]. It only supports errors returned by
// the os package. New code should use errors.Is(err, fs.ErrNotExist).

joshuacolvin0
joshuacolvin0 previously approved these changes Aug 27, 2024
Copy link
Member

@joshuacolvin0 joshuacolvin0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

diegoximenes
diegoximenes previously approved these changes Aug 27, 2024
@PlasmaPower PlasmaPower merged commit e7e9d1b into master Aug 27, 2024
13 checks passed
@PlasmaPower PlasmaPower deleted the fix-is-not-exist-error branch August 27, 2024 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design-approved s Automatically added by the CLA bot if the creator of a PR is registered as having signed the CLA.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants