github.com/pwn-term/docker@v0.0.0-20210616085119-6e977cce2565/moby/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  func translateV2AuthError(err error) error {
    11  	switch e := err.(type) {
    12  	case *url.Error:
    13  		switch e2 := e.Err.(type) {
    14  		case errcode.Error:
    15  			switch e2.Code {
    16  			case errcode.ErrorCodeUnauthorized:
    17  				return errdefs.Unauthorized(err)
    18  			}
    19  		}
    20  	}
    21  
    22  	return err
    23  }