2015-04-16 05:01:29 +00:00
|
|
|
package libnetwork
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
2015-05-14 21:56:15 +00:00
|
|
|
// ErrNoSuchNetwork is returned when a network query finds no result
|
|
|
|
type ErrNoSuchNetwork string
|
|
|
|
|
|
|
|
func (nsn ErrNoSuchNetwork) Error() string {
|
|
|
|
return fmt.Sprintf("network %s not found", string(nsn))
|
|
|
|
}
|
|
|
|
|
2015-06-09 23:38:11 +00:00
|
|
|
// NotFound denotes the type of this error
|
|
|
|
func (nsn ErrNoSuchNetwork) NotFound() {}
|
2015-05-14 21:56:15 +00:00
|
|
|
|
2016-05-23 02:55:17 +00:00
|
|
|
// ErrNoSuchEndpoint is returned when an endpoint query finds no result
|
2015-05-14 21:56:15 +00:00
|
|
|
type ErrNoSuchEndpoint string
|
|
|
|
|
|
|
|
func (nse ErrNoSuchEndpoint) Error() string {
|
|
|
|
return fmt.Sprintf("endpoint %s not found", string(nse))
|
|
|
|
}
|
|
|
|
|
2015-06-09 23:38:11 +00:00
|
|
|
// NotFound denotes the type of this error
|
|
|
|
func (nse ErrNoSuchEndpoint) NotFound() {}
|
2015-05-14 21:56:15 +00:00
|
|
|
|
|
|
|
// ErrInvalidID is returned when a query-by-id method is being invoked
|
|
|
|
// with an empty id parameter
|
|
|
|
type ErrInvalidID string
|
|
|
|
|
|
|
|
func (ii ErrInvalidID) Error() string {
|
|
|
|
return fmt.Sprintf("invalid id: %s", string(ii))
|
|
|
|
}
|
|
|
|
|
2023-08-08 11:35:05 +00:00
|
|
|
// InvalidParameter denotes the type of this error
|
|
|
|
func (ii ErrInvalidID) InvalidParameter() {}
|
2015-05-14 21:56:15 +00:00
|
|
|
|
|
|
|
// ErrInvalidName is returned when a query-by-name or resource create method is
|
2017-02-02 02:17:29 +00:00
|
|
|
// invoked with an empty name parameter
|
2015-05-14 21:56:15 +00:00
|
|
|
type ErrInvalidName string
|
|
|
|
|
|
|
|
func (in ErrInvalidName) Error() string {
|
|
|
|
return fmt.Sprintf("invalid name: %s", string(in))
|
|
|
|
}
|
|
|
|
|
2023-08-08 11:35:05 +00:00
|
|
|
// InvalidParameter denotes the type of this error
|
|
|
|
func (in ErrInvalidName) InvalidParameter() {}
|
2015-04-16 05:01:29 +00:00
|
|
|
|
|
|
|
// NetworkNameError is returned when a network with the same name already exists.
|
|
|
|
type NetworkNameError string
|
|
|
|
|
2015-05-14 21:56:15 +00:00
|
|
|
func (nnr NetworkNameError) Error() string {
|
|
|
|
return fmt.Sprintf("network with name %s already exists", string(nnr))
|
2015-04-16 05:01:29 +00:00
|
|
|
}
|
|
|
|
|
2023-08-07 21:08:10 +00:00
|
|
|
// Conflict denotes the type of this error
|
|
|
|
func (nnr NetworkNameError) Conflict() {}
|
2015-05-14 21:56:15 +00:00
|
|
|
|
2016-10-28 17:04:22 +00:00
|
|
|
// UnknownNetworkError is returned when libnetwork could not find in its database
|
2015-04-16 05:01:29 +00:00
|
|
|
// a network with the same name and id.
|
|
|
|
type UnknownNetworkError struct {
|
|
|
|
name string
|
|
|
|
id string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (une *UnknownNetworkError) Error() string {
|
|
|
|
return fmt.Sprintf("unknown network %s id %s", une.name, une.id)
|
|
|
|
}
|
|
|
|
|
2015-05-14 21:56:15 +00:00
|
|
|
// NotFound denotes the type of this error
|
|
|
|
func (une *UnknownNetworkError) NotFound() {}
|
|
|
|
|
2015-04-16 05:01:29 +00:00
|
|
|
// ActiveEndpointsError is returned when a network is deleted which has active
|
|
|
|
// endpoints in it.
|
|
|
|
type ActiveEndpointsError struct {
|
|
|
|
name string
|
|
|
|
id string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (aee *ActiveEndpointsError) Error() string {
|
2017-01-11 09:19:06 +00:00
|
|
|
return fmt.Sprintf("network %s id %s has active endpoints", aee.name, aee.id)
|
2015-04-16 05:01:29 +00:00
|
|
|
}
|
|
|
|
|
2015-05-14 21:56:15 +00:00
|
|
|
// Forbidden denotes the type of this error
|
|
|
|
func (aee *ActiveEndpointsError) Forbidden() {}
|
|
|
|
|
2015-05-06 20:02:40 +00:00
|
|
|
// ActiveContainerError is returned when an endpoint is deleted which has active
|
|
|
|
// containers attached to it.
|
|
|
|
type ActiveContainerError struct {
|
|
|
|
name string
|
|
|
|
id string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ace *ActiveContainerError) Error() string {
|
|
|
|
return fmt.Sprintf("endpoint with name %s id %s has active containers", ace.name, ace.id)
|
|
|
|
}
|
|
|
|
|
2015-05-14 21:56:15 +00:00
|
|
|
// Forbidden denotes the type of this error
|
|
|
|
func (ace *ActiveContainerError) Forbidden() {}
|
|
|
|
|
2016-05-24 23:17:19 +00:00
|
|
|
// ManagerRedirectError is returned when the request should be redirected to Manager
|
|
|
|
type ManagerRedirectError string
|
|
|
|
|
|
|
|
func (mr ManagerRedirectError) Error() string {
|
|
|
|
return "Redirect the request to the manager"
|
|
|
|
}
|
|
|
|
|
|
|
|
// Maskable denotes the type of this error
|
|
|
|
func (mr ManagerRedirectError) Maskable() {}
|