github.com/khulnasoft-lab/khulnasoft@v26.0.1-0.20240328202558-330a6f959fe0+incompatible/libnetwork/error.go (about) 1 package libnetwork 2 3 import ( 4 "fmt" 5 ) 6 7 // ErrNoSuchNetwork is returned when a network query finds no result 8 type ErrNoSuchNetwork string 9 10 func (nsn ErrNoSuchNetwork) Error() string { 11 return fmt.Sprintf("network %s not found", string(nsn)) 12 } 13 14 // NotFound denotes the type of this error 15 func (nsn ErrNoSuchNetwork) NotFound() {} 16 17 // ErrNoSuchEndpoint is returned when an endpoint query finds no result 18 type ErrNoSuchEndpoint string 19 20 func (nse ErrNoSuchEndpoint) Error() string { 21 return fmt.Sprintf("endpoint %s not found", string(nse)) 22 } 23 24 // NotFound denotes the type of this error 25 func (nse ErrNoSuchEndpoint) NotFound() {} 26 27 // ErrInvalidID is returned when a query-by-id method is being invoked 28 // with an empty id parameter 29 type ErrInvalidID string 30 31 func (ii ErrInvalidID) Error() string { 32 return fmt.Sprintf("invalid id: %s", string(ii)) 33 } 34 35 // InvalidParameter denotes the type of this error 36 func (ii ErrInvalidID) InvalidParameter() {} 37 38 // ErrInvalidName is returned when a query-by-name or resource create method is 39 // invoked with an empty name parameter 40 type ErrInvalidName string 41 42 func (in ErrInvalidName) Error() string { 43 return fmt.Sprintf("invalid name: %s", string(in)) 44 } 45 46 // InvalidParameter denotes the type of this error 47 func (in ErrInvalidName) InvalidParameter() {} 48 49 // NetworkNameError is returned when a network with the same name already exists. 50 type NetworkNameError string 51 52 func (nnr NetworkNameError) Error() string { 53 return fmt.Sprintf("network with name %s already exists", string(nnr)) 54 } 55 56 // Conflict denotes the type of this error 57 func (nnr NetworkNameError) Conflict() {} 58 59 // UnknownNetworkError is returned when libnetwork could not find in its database 60 // a network with the same name and id. 61 type UnknownNetworkError struct { 62 name string 63 id string 64 } 65 66 func (une *UnknownNetworkError) Error() string { 67 return fmt.Sprintf("unknown network %s id %s", une.name, une.id) 68 } 69 70 // NotFound denotes the type of this error 71 func (une *UnknownNetworkError) NotFound() {} 72 73 // ActiveEndpointsError is returned when a network is deleted which has active 74 // endpoints in it. 75 type ActiveEndpointsError struct { 76 name string 77 id string 78 } 79 80 func (aee *ActiveEndpointsError) Error() string { 81 return fmt.Sprintf("network %s id %s has active endpoints", aee.name, aee.id) 82 } 83 84 // Forbidden denotes the type of this error 85 func (aee *ActiveEndpointsError) Forbidden() {} 86 87 // ActiveContainerError is returned when an endpoint is deleted which has active 88 // containers attached to it. 89 type ActiveContainerError struct { 90 name string 91 id string 92 } 93 94 func (ace *ActiveContainerError) Error() string { 95 return fmt.Sprintf("endpoint with name %s id %s has active containers", ace.name, ace.id) 96 } 97 98 // Forbidden denotes the type of this error 99 func (ace *ActiveContainerError) Forbidden() {} 100 101 // ManagerRedirectError is returned when the request should be redirected to Manager 102 type ManagerRedirectError string 103 104 func (mr ManagerRedirectError) Error() string { 105 return "Redirect the request to the manager" 106 } 107 108 // Maskable denotes the type of this error 109 func (mr ManagerRedirectError) Maskable() {}