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

Use errors.As() and errors.Is() to unwrap errors #2291

Merged
merged 2 commits into from
Apr 3, 2020

Conversation

kolyshkin
Copy link
Contributor

My previous attempt (#2280) was a bit immature (though it worked).

Using errors.Unwrap() is not the best thing to do, since it returns
nil in case of an error which was not wrapped. More to say,
errors package provides more elegant ways to check for underlying
errors, such as errors.As() and errors.Is().

Revert #2280, and use errors.Is() and errors.As()

Make use of errors.Is() and errors.As() where appropriate to check
the underlying error. The biggest motivation is to simplify the code.

The feature requires go 1.13 but since merging #2256 we are already
not supporting go 1.12 (which is an unsupported release anyway).

…unwrap"

Using errors.Unwrap() is not the best thing to do, since it returns
nil in case of an error which was not wrapped. More to say,
errors package provides more elegant ways to check for underlying
errors, such as errors.As() and errors.Is().

This reverts commit f8e1388, reversing
changes made to 6ca9d8e.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Make use of errors.Is() and errors.As() where appropriate to check
the underlying error. The biggest motivation is to simplify the code.

The feature requires go 1.13 but since merging opencontainers#2256 we are already
not supporting go 1.12 (which is an unsupported release anyway).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
@kolyshkin
Copy link
Contributor Author

@AkihiroSuda @crosbymichael @mrunalp PTAL

@AkihiroSuda
Copy link
Member

AkihiroSuda commented Apr 3, 2020

LGTM

Approved with PullApprove

@mrunalp
Copy link
Contributor

mrunalp commented Apr 3, 2020

LGTM

Approved with PullApprove

@kolyshkin kolyshkin changed the title Revert "Merge pull request #2280 from kolyshkin/errors-unwrap" Use errors.As() and errors.Is() to unwrap errors Apr 3, 2020
@crosbymichael
Copy link
Member

crosbymichael commented Apr 3, 2020

LGTM

Approved with PullApprove

@crosbymichael crosbymichael merged commit e4363b0 into opencontainers:master Apr 3, 2020
kolyshkin added a commit to kolyshkin/runc that referenced this pull request Apr 18, 2020
This is a forgotten hunk from PR opencontainers#2291.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
@kolyshkin kolyshkin mentioned this pull request Apr 18, 2020
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.

4 participants