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

Expose typed errors as a stable interface to prevent unnecessary hcsshim dependencies #148

Open
darstahl opened this issue Nov 8, 2017 · 0 comments

Comments

@darstahl
Copy link
Contributor

darstahl commented Nov 8, 2017

This is just a thought that I'm posting as an issue to keep track of it.

Currently, in order to determine if an error is caused by a missing resource in hcsshim, clients need to take a dependency on hcsshim and use hcsshim.IsNotFound(). This is better than raw errors and error strings, but I think it could be done in a more scale-able way.

I wonder if we could do this in a more generic way in the future, such that clients who want to determine if an error is caused by a resource not existing do not need to take a dependency on hcsshim (assuming the hcsshim error filters a few layers, or even projects, above where it is read).

I think this would be best done with something like https://github.com/pkg/errors for Cause wrapping instead of my current implementation of getInnerError and an unexported (but guaranteed stable) isNotFound interface with some method such as .NotFound() and errors which implement that method. Clients could then just define the same interface in their code and at runtime determine if the error is caused by a missing resource without needing to know which underlying package caused the error.

This would be best defined outside hcsshim so that other platform layers could implement the same interface, and it is not just Microsoft/* that uses it. I don't have the time to look into if something like this already exists in Go, but storing this to come back to it at a later date. If not, pkg/errors might want to host something like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant