github.com/mforkel/docker-ce-i386@v17.12.1-ce-rc2+incompatible/components/engine/registry/errors.go (about) 1 package registry 2 3 import ( 4 "net/url" 5 6 "github.com/docker/distribution/registry/api/errcode" 7 ) 8 9 type notFoundError string 10 11 func (e notFoundError) Error() string { 12 return string(e) 13 } 14 15 func (notFoundError) NotFound() {} 16 17 type validationError struct { 18 cause error 19 } 20 21 func (e validationError) Error() string { 22 return e.cause.Error() 23 } 24 25 func (e validationError) InvalidParameter() {} 26 27 func (e validationError) Cause() error { 28 return e.cause 29 } 30 31 type unauthorizedError struct { 32 cause error 33 } 34 35 func (e unauthorizedError) Error() string { 36 return e.cause.Error() 37 } 38 39 func (e unauthorizedError) Unauthorized() {} 40 41 func (e unauthorizedError) Cause() error { 42 return e.cause 43 } 44 45 type systemError struct { 46 cause error 47 } 48 49 func (e systemError) Error() string { 50 return e.cause.Error() 51 } 52 53 func (e systemError) SystemError() {} 54 55 func (e systemError) Cause() error { 56 return e.cause 57 } 58 59 type notActivatedError struct { 60 cause error 61 } 62 63 func (e notActivatedError) Error() string { 64 return e.cause.Error() 65 } 66 67 func (e notActivatedError) Forbidden() {} 68 69 func (e notActivatedError) Cause() error { 70 return e.cause 71 } 72 73 func translateV2AuthError(err error) error { 74 switch e := err.(type) { 75 case *url.Error: 76 switch e2 := e.Err.(type) { 77 case errcode.Error: 78 switch e2.Code { 79 case errcode.ErrorCodeUnauthorized: 80 return unauthorizedError{err} 81 } 82 } 83 } 84 85 return err 86 }