code: func retryOnError(err error) error {
  	switch v := err.(type) {
  	case errcode.Errors:
  		if len(v) != 0 {
  			return retryOnError(v[0])
  		}
  	case errcode.Error:
  		switch v.Code {
  		case errcode.ErrorCodeUnauthorized, errcode.ErrorCodeUnsupported, errcode.ErrorCodeDenied, errcode.ErrorCodeTooManyRequests, v2.ErrorCodeNameUnknown:
  			return xfer.DoNotRetry{Err: err}
  		}
  	case *url.Error:
  		switch v.Err {
  		case auth.ErrNoBasicAuthCredentials, auth.ErrNoToken:
  			return xfer.DoNotRetry{Err: v.Err}
  		}
  		return retryOnError(v.Err)
  	case *client.UnexpectedHTTPResponseError:
  		return xfer.DoNotRetry{Err: err}
  	case error:
  		if err == distribution.ErrBlobUnknown {
  			return xfer.DoNotRetry{Err: err}
  		}
  		if strings.Contains(err.Error(), strings.ToLower(syscall.ENOSPC.Error())) {
  			return xfer.DoNotRetry{Err: err}
  		}
  	}
  	// let's be nice and fallback if the error is a completely
  	// unexpected one.
  	// If new errors have to be handled in some way, please
  	// add them to the switch above.
  	return err
  }
docs: // retryOnError wraps the error in xfer.DoNotRetry if we should not retry the
  // operation after this error.