errors.go 521 B

12345678910111213141516171819202122232425262728293031
  1. package registry
  2. import (
  3. "net/url"
  4. "github.com/docker/distribution/registry/api/errcode"
  5. "github.com/docker/docker/errdefs"
  6. )
  7. type notFoundError string
  8. func (e notFoundError) Error() string {
  9. return string(e)
  10. }
  11. func (notFoundError) NotFound() {}
  12. func translateV2AuthError(err error) error {
  13. switch e := err.(type) {
  14. case *url.Error:
  15. switch e2 := e.Err.(type) {
  16. case errcode.Error:
  17. switch e2.Code {
  18. case errcode.ErrorCodeUnauthorized:
  19. return errdefs.Unauthorized(err)
  20. }
  21. }
  22. }
  23. return err
  24. }