Support Unwrap for hcserror
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 694
- Forks
- 304
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 28
Description
Go 1.13 introduced the Unwrap method which allows examining wrapped errors more-cleanly via errors.Is.
It'd be handy to support that on hcsshim.HcsError to support cases like
// ERROR_DEV_NOT_EXIST is returned if the layer is not currently prepared.
if err := hcsshim.UnprepareLayer(info, filepath.Base(layerPath)); err != nil {
if hcserror, ok := err.(*hcsshim.HcsError); !ok || hcserror.Err != windows.ERROR_DEV_NOT_EXIST {
return errors.Wrapf(err, "failed to unprepare %s", layerPath)
}
}
which could just be
// ERROR_DEV_NOT_EXIST is returned if the layer is not currently prepared.
if err := hcsshim.UnprepareLayer(info, filepath.Base(layerPath)); err != nil && !err.Is(windows.ERROR_DEV_NOT_EXIST) {
return errors.Wrapf(err, "failed to unprepare %s", layerPath)
}
.
(See https://github.com/containerd/containerd/pull/5133)
It should be a fairly easy addition, since HcsError already carries a public Err field.
Even if we still need to support Go 1.12 and earlier, this would provide compatibility with the golang.org/x/xerrors backfill, and won't otherwise hurt.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the HcsError definition and checking how its public Err field is currently exposed; then run the package's existing tests. Done means HcsError supports Go error unwrapping so callers can use errors.Is or xerrors compatibility with the underlying error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- operating-systems
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100