It was only returned in a few places, and not used any different than
a "invalid parameter" error, so let's use a standard errdefs.ErrInvalidParameter
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -474,7 +474,7 @@ func (c *Controller) NewNetwork(networkType, name string, id string, options ... |
| 474 | 474 |
} |
| 475 | 475 |
|
| 476 | 476 |
if strings.TrimSpace(name) == "" {
|
| 477 |
- return nil, ErrInvalidName(name) |
|
| 477 |
+ return nil, types.InvalidParameterErrorf("invalid name: name is empty")
|
|
| 478 | 478 |
} |
| 479 | 479 |
|
| 480 | 480 |
// Make sure two concurrent calls to this method won't create conflicting |
| ... | ... |
@@ -837,7 +837,7 @@ func (c *Controller) WalkNetworks(walker NetworkWalker) {
|
| 837 | 837 |
// If not found, the error [ErrNoSuchNetwork] is returned. |
| 838 | 838 |
func (c *Controller) NetworkByName(name string) (*Network, error) {
|
| 839 | 839 |
if name == "" {
|
| 840 |
- return nil, ErrInvalidName(name) |
|
| 840 |
+ return nil, types.InvalidParameterErrorf("invalid name: name is empty")
|
|
| 841 | 841 |
} |
| 842 | 842 |
var n *Network |
| 843 | 843 |
|
| ... | ... |
@@ -14,17 +14,6 @@ func (nsn ErrNoSuchNetwork) Error() string {
|
| 14 | 14 |
// NotFound denotes the type of this error |
| 15 | 15 |
func (nsn ErrNoSuchNetwork) NotFound() {}
|
| 16 | 16 |
|
| 17 |
-// ErrInvalidName is returned when a query-by-name or resource create method is |
|
| 18 |
-// invoked with an empty name parameter |
|
| 19 |
-type ErrInvalidName string |
|
| 20 |
- |
|
| 21 |
-func (in ErrInvalidName) Error() string {
|
|
| 22 |
- return fmt.Sprintf("invalid name: %s", string(in))
|
|
| 23 |
-} |
|
| 24 |
- |
|
| 25 |
-// InvalidParameter denotes the type of this error |
|
| 26 |
-func (in ErrInvalidName) InvalidParameter() {}
|
|
| 27 |
- |
|
| 28 | 17 |
// NetworkNameError is returned when a network with the same name already exists. |
| 29 | 18 |
type NetworkNameError string |
| 30 | 19 |
|
| ... | ... |
@@ -10,11 +10,6 @@ import ( |
| 10 | 10 |
) |
| 11 | 11 |
|
| 12 | 12 |
func TestErrorInterfaces(t *testing.T) {
|
| 13 |
- badRequestErrorList := []error{ErrInvalidName("")}
|
|
| 14 |
- for _, err := range badRequestErrorList {
|
|
| 15 |
- assert.Check(t, is.ErrorType(err, errdefs.IsInvalidParameter)) |
|
| 16 |
- } |
|
| 17 |
- |
|
| 18 | 13 |
maskableErrorList := []error{ManagerRedirectError("")}
|
| 19 | 14 |
for _, err := range maskableErrorList {
|
| 20 | 15 |
switch u := err.(type) {
|
| ... | ... |
@@ -1177,7 +1177,7 @@ func (n *Network) addEndpoint(ctx context.Context, ep *Endpoint) error {
|
| 1177 | 1177 |
func (n *Network) CreateEndpoint(ctx context.Context, name string, options ...EndpointOption) (*Endpoint, error) {
|
| 1178 | 1178 |
var err error |
| 1179 | 1179 |
if strings.TrimSpace(name) == "" {
|
| 1180 |
- return nil, ErrInvalidName(name) |
|
| 1180 |
+ return nil, types.InvalidParameterErrorf("invalid name: name is empty")
|
|
| 1181 | 1181 |
} |
| 1182 | 1182 |
|
| 1183 | 1183 |
if n.ConfigOnly() {
|
| ... | ... |
@@ -1313,7 +1313,7 @@ func (n *Network) WalkEndpoints(walker EndpointWalker) {
|
| 1313 | 1313 |
// an [errdefs.ErrNotFound] is returned. |
| 1314 | 1314 |
func (n *Network) EndpointByName(name string) (*Endpoint, error) {
|
| 1315 | 1315 |
if name == "" {
|
| 1316 |
- return nil, ErrInvalidName(name) |
|
| 1316 |
+ return nil, types.InvalidParameterErrorf("invalid name: name is empty")
|
|
| 1317 | 1317 |
} |
| 1318 | 1318 |
var e *Endpoint |
| 1319 | 1319 |
|