github.com/devdivbcp/moby@v17.12.0-ce-rc1.0.20200726071732-2d4bfdc789ad+incompatible/registry/errors.go (about)

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