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

janitorial: modernize error detection #233

Merged
merged 1 commit into from
Mar 9, 2021

Conversation

ffromani
Copy link
Collaborator

@ffromani ffromani commented Mar 9, 2021

Reading the documentation of os.IsNotExist and similar functions
(see https://golang.org/pkg/os/#IsNotExist), we learn that

This function predates errors.Is. It only supports errors returned
by the os package. New code should use errors.Is(err, os.ErrNotExist).

ghw uses these functions but sparsely, so we take the chance
in this PR to modernize the codebase.

No intended changes in behaviour.

Signed-off-by: Francesco Romani fromani@redhat.com

Reading the documentation of `os.IsNotExist` and similar functions
(see https://golang.org/pkg/os/#IsNotExist), we learn that

```
This function predates errors.Is. It only supports errors returned
by the os package. New code should use errors.Is(err, os.ErrNotExist).
```

ghw uses these functions but sparsely, so we take the chance
in this PR to modernize the codebase.

No intended changes in behaviour.

Signed-off-by: Francesco Romani <fromani@redhat.com>
Copy link
Owner

@jaypipes jaypipes left a comment

Choose a reason for hiding this comment

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

Nice @fromanirh :)

@jaypipes jaypipes merged commit 1a1bc99 into jaypipes:master Mar 9, 2021
@jaypipes jaypipes added this to the v0.7 milestone Mar 9, 2021
@ffromani ffromani deleted the modernize-errors branch March 9, 2021 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants