github.com/zhuohuang-hust/src-cbuild@v0.0.0-20230105071821-c7aab3e7c840/mergeCode/libnetwork/drivers/solaris/bridge/errors.go (about)

     1  package bridge
     2  
     3  import "fmt"
     4  
     5  // ErrInvalidEndpointConfig error is returned when an endpoint create is attempted with an invalid endpoint configuration.
     6  type ErrInvalidEndpointConfig struct{}
     7  
     8  func (eiec *ErrInvalidEndpointConfig) Error() string {
     9  	return "trying to create an endpoint with an invalid endpoint configuration"
    10  }
    11  
    12  // BadRequest denotes the type of this error
    13  func (eiec *ErrInvalidEndpointConfig) BadRequest() {}
    14  
    15  // ErrNoIPAddr error is returned when bridge has no IPv4 address configured.
    16  type ErrNoIPAddr struct{}
    17  
    18  func (enip *ErrNoIPAddr) Error() string {
    19  	return "bridge has no IPv4 address configured"
    20  }
    21  
    22  // InternalError denotes the type of this error
    23  func (enip *ErrNoIPAddr) InternalError() {}
    24  
    25  // ErrInvalidGateway is returned when the user provided default gateway (v4/v6) is not not valid.
    26  type ErrInvalidGateway struct{}
    27  
    28  func (eig *ErrInvalidGateway) Error() string {
    29  	return "default gateway ip must be part of the network"
    30  }
    31  
    32  // BadRequest denotes the type of this error
    33  func (eig *ErrInvalidGateway) BadRequest() {}
    34  
    35  // ErrInvalidMtu is returned when the user provided MTU is not valid.
    36  type ErrInvalidMtu int
    37  
    38  func (eim ErrInvalidMtu) Error() string {
    39  	return fmt.Sprintf("invalid MTU number: %d", int(eim))
    40  }
    41  
    42  // BadRequest denotes the type of this error
    43  func (eim ErrInvalidMtu) BadRequest() {}
    44  
    45  // ErrUnsupportedAddressType is returned when the specified address type is not supported.
    46  type ErrUnsupportedAddressType string
    47  
    48  func (uat ErrUnsupportedAddressType) Error() string {
    49  	return fmt.Sprintf("unsupported address type: %s", string(uat))
    50  }
    51  
    52  // BadRequest denotes the type of this error
    53  func (uat ErrUnsupportedAddressType) BadRequest() {}
    54  
    55  // ActiveEndpointsError is returned when there are
    56  // still active endpoints in the network being deleted.
    57  type ActiveEndpointsError string
    58  
    59  func (aee ActiveEndpointsError) Error() string {
    60  	return fmt.Sprintf("network %s has active endpoint", string(aee))
    61  }
    62  
    63  // Forbidden denotes the type of this error
    64  func (aee ActiveEndpointsError) Forbidden() {}
    65  
    66  // InvalidNetworkIDError is returned when the passed
    67  // network id for an existing network is not a known id.
    68  type InvalidNetworkIDError string
    69  
    70  func (inie InvalidNetworkIDError) Error() string {
    71  	return fmt.Sprintf("invalid network id %s", string(inie))
    72  }
    73  
    74  // NotFound denotes the type of this error
    75  func (inie InvalidNetworkIDError) NotFound() {}
    76  
    77  // InvalidEndpointIDError is returned when the passed
    78  // endpoint id is not valid.
    79  type InvalidEndpointIDError string
    80  
    81  func (ieie InvalidEndpointIDError) Error() string {
    82  	return fmt.Sprintf("invalid endpoint id: %s", string(ieie))
    83  }
    84  
    85  // BadRequest denotes the type of this error
    86  func (ieie InvalidEndpointIDError) BadRequest() {}
    87  
    88  // EndpointNotFoundError is returned when the no endpoint
    89  // with the passed endpoint id is found.
    90  type EndpointNotFoundError string
    91  
    92  func (enfe EndpointNotFoundError) Error() string {
    93  	return fmt.Sprintf("endpoint not found: %s", string(enfe))
    94  }
    95  
    96  // NotFound denotes the type of this error
    97  func (enfe EndpointNotFoundError) NotFound() {}
    98  
    99  // NonDefaultBridgeExistError is returned when a non-default
   100  // bridge config is passed but it does not already exist.
   101  type NonDefaultBridgeExistError string
   102  
   103  func (ndbee NonDefaultBridgeExistError) Error() string {
   104  	return fmt.Sprintf("bridge device with non default name %s must be created manually", string(ndbee))
   105  }
   106  
   107  // Forbidden denotes the type of this error
   108  func (ndbee NonDefaultBridgeExistError) Forbidden() {}
   109  
   110  // NonDefaultBridgeNeedsIPError is returned when a non-default
   111  // bridge config is passed but it has no ip configured
   112  type NonDefaultBridgeNeedsIPError string
   113  
   114  func (ndbee NonDefaultBridgeNeedsIPError) Error() string {
   115  	return fmt.Sprintf("bridge device with non default name %s must have a valid IP address", string(ndbee))
   116  }
   117  
   118  // Forbidden denotes the type of this error
   119  func (ndbee NonDefaultBridgeNeedsIPError) Forbidden() {}