Use errors.Unwrap() where possible#2280
Merged
crosbymichael merged 6 commits intoopencontainers:masterfrom Apr 2, 2020
Merged
Conversation
This simplifies code a lot. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Tested that the EINTR is still being detected: > $ go1.14 test -c # 1.14 is needed for EINTR to happen > $ sudo ./fscommon.test > INFO[0000] interrupted while writing 1063068 to /sys/fs/cgroup/memory/test-eint-89293785/memory.limit_in_bytes > PASS Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Contributor
Author
|
Let me know if you want me to merge most of the commits (or all of them) |
Member
1 similar comment
Member
Contributor
Author
|
Oh well, this might not be working as I thought it would. See this example: https://play.golang.org/p/-HyjwI4v_pz IOW if an error is not wrapped, |
Member
|
We should revert this PR? |
kolyshkin
commented
Apr 3, 2020
| errno = err.Err | ||
| } | ||
| // Handle some specific syscall errors. | ||
| errno := errors.Unwrap(err) |
Contributor
Author
There was a problem hiding this comment.
This code might not be working the way it should. If err is not wrapped, errno will be nil.
Will do a followup PR.
kolyshkin
added a commit
to kolyshkin/runc
that referenced
this pull request
Apr 3, 2020
…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>
Contributor
Author
@AkihiroSuda while I don't see any code paths that might hit the problem I described above, it's better to not use |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This set makes use of errors.Unwrap() where possible to get to an 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).