github.com/Heebron/moby@v0.0.0-20221111184709-6eab4f55faf7/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  // ErrInvalidNetworkDriver is returned if an invalid driver
    28  // name is passed.
    29  type ErrInvalidNetworkDriver string
    30  
    31  func (ind ErrInvalidNetworkDriver) Error() string {
    32  	return fmt.Sprintf("invalid driver bound to network: %s", string(ind))
    33  }
    34  
    35  // BadRequest denotes the type of this error
    36  func (ind ErrInvalidNetworkDriver) BadRequest() {}
    37  
    38  // ErrInvalidJoin is returned if a join is attempted on an endpoint
    39  // which already has a container joined.
    40  type ErrInvalidJoin struct{}
    41  
    42  func (ij ErrInvalidJoin) Error() string {
    43  	return "a container has already joined the endpoint"
    44  }
    45  
    46  // BadRequest denotes the type of this error
    47  func (ij ErrInvalidJoin) BadRequest() {}
    48  
    49  // ErrNoContainer is returned when the endpoint has no container
    50  // attached to it.
    51  type ErrNoContainer struct{}
    52  
    53  func (nc ErrNoContainer) Error() string {
    54  	return "no container is attached to the endpoint"
    55  }
    56  
    57  // Maskable denotes the type of this error
    58  func (nc ErrNoContainer) Maskable() {}
    59  
    60  // ErrInvalidID is returned when a query-by-id method is being invoked
    61  // with an empty id parameter
    62  type ErrInvalidID string
    63  
    64  func (ii ErrInvalidID) Error() string {
    65  	return fmt.Sprintf("invalid id: %s", string(ii))
    66  }
    67  
    68  // BadRequest denotes the type of this error
    69  func (ii ErrInvalidID) BadRequest() {}
    70  
    71  // ErrInvalidName is returned when a query-by-name or resource create method is
    72  // invoked with an empty name parameter
    73  type ErrInvalidName string
    74  
    75  func (in ErrInvalidName) Error() string {
    76  	return fmt.Sprintf("invalid name: %s", string(in))
    77  }
    78  
    79  // BadRequest denotes the type of this error
    80  func (in ErrInvalidName) BadRequest() {}
    81  
    82  // ErrInvalidConfigFile type is returned when an invalid LibNetwork config file is detected
    83  type ErrInvalidConfigFile string
    84  
    85  func (cf ErrInvalidConfigFile) Error() string {
    86  	return fmt.Sprintf("Invalid Config file %q", string(cf))
    87  }
    88  
    89  // NetworkTypeError type is returned when the network type string is not
    90  // known to libnetwork.
    91  type NetworkTypeError string
    92  
    93  func (nt NetworkTypeError) Error() string {
    94  	return fmt.Sprintf("unknown driver %q", string(nt))
    95  }
    96  
    97  // NotFound denotes the type of this error
    98  func (nt NetworkTypeError) NotFound() {}
    99  
   100  // NetworkNameError is returned when a network with the same name already exists.
   101  type NetworkNameError string
   102  
   103  func (nnr NetworkNameError) Error() string {
   104  	return fmt.Sprintf("network with name %s already exists", string(nnr))
   105  }
   106  
   107  // Forbidden denotes the type of this error
   108  func (nnr NetworkNameError) Forbidden() {}
   109  
   110  // UnknownNetworkError is returned when libnetwork could not find in its database
   111  // a network with the same name and id.
   112  type UnknownNetworkError struct {
   113  	name string
   114  	id   string
   115  }
   116  
   117  func (une *UnknownNetworkError) Error() string {
   118  	return fmt.Sprintf("unknown network %s id %s", une.name, une.id)
   119  }
   120  
   121  // NotFound denotes the type of this error
   122  func (une *UnknownNetworkError) NotFound() {}
   123  
   124  // ActiveEndpointsError is returned when a network is deleted which has active
   125  // endpoints in it.
   126  type ActiveEndpointsError struct {
   127  	name string
   128  	id   string
   129  }
   130  
   131  func (aee *ActiveEndpointsError) Error() string {
   132  	return fmt.Sprintf("network %s id %s has active endpoints", aee.name, aee.id)
   133  }
   134  
   135  // Forbidden denotes the type of this error
   136  func (aee *ActiveEndpointsError) Forbidden() {}
   137  
   138  // UnknownEndpointError is returned when libnetwork could not find in its database
   139  // an endpoint with the same name and id.
   140  type UnknownEndpointError struct {
   141  	name string
   142  	id   string
   143  }
   144  
   145  func (uee *UnknownEndpointError) Error() string {
   146  	return fmt.Sprintf("unknown endpoint %s id %s", uee.name, uee.id)
   147  }
   148  
   149  // NotFound denotes the type of this error
   150  func (uee *UnknownEndpointError) NotFound() {}
   151  
   152  // ActiveContainerError is returned when an endpoint is deleted which has active
   153  // containers attached to it.
   154  type ActiveContainerError struct {
   155  	name string
   156  	id   string
   157  }
   158  
   159  func (ace *ActiveContainerError) Error() string {
   160  	return fmt.Sprintf("endpoint with name %s id %s has active containers", ace.name, ace.id)
   161  }
   162  
   163  // Forbidden denotes the type of this error
   164  func (ace *ActiveContainerError) Forbidden() {}
   165  
   166  // InvalidContainerIDError is returned when an invalid container id is passed
   167  // in Join/Leave
   168  type InvalidContainerIDError string
   169  
   170  func (id InvalidContainerIDError) Error() string {
   171  	return fmt.Sprintf("invalid container id %s", string(id))
   172  }
   173  
   174  // BadRequest denotes the type of this error
   175  func (id InvalidContainerIDError) BadRequest() {}
   176  
   177  // ManagerRedirectError is returned when the request should be redirected to Manager
   178  type ManagerRedirectError string
   179  
   180  func (mr ManagerRedirectError) Error() string {
   181  	return "Redirect the request to the manager"
   182  }
   183  
   184  // Maskable denotes the type of this error
   185  func (mr ManagerRedirectError) Maskable() {}
   186  
   187  // ErrDataStoreNotInitialized is returned if an invalid data scope is passed
   188  // for getting data store
   189  type ErrDataStoreNotInitialized string
   190  
   191  func (dsni ErrDataStoreNotInitialized) Error() string {
   192  	return fmt.Sprintf("datastore for scope %q is not initialized", string(dsni))
   193  }