errors.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package driverapi
  2. import (
  3. "fmt"
  4. )
  5. // ErrNoNetwork is returned if no network with the specified id exists
  6. type ErrNoNetwork string
  7. func (enn ErrNoNetwork) Error() string {
  8. return fmt.Sprintf("No network (%s) exists", string(enn))
  9. }
  10. // NotFound denotes the type of this error
  11. func (enn ErrNoNetwork) NotFound() {}
  12. // ErrEndpointExists is returned if more than one endpoint is added to the network
  13. type ErrEndpointExists string
  14. func (ee ErrEndpointExists) Error() string {
  15. return fmt.Sprintf("Endpoint (%s) already exists (Only one endpoint allowed)", string(ee))
  16. }
  17. // Forbidden denotes the type of this error
  18. func (ee ErrEndpointExists) Forbidden() {}
  19. // ErrNotImplemented is returned when a Driver has not implemented an API yet
  20. type ErrNotImplemented struct{}
  21. func (eni *ErrNotImplemented) Error() string {
  22. return "The API is not implemented yet"
  23. }
  24. // NotImplemented denotes the type of this error
  25. func (eni *ErrNotImplemented) NotImplemented() {}
  26. // ErrNoEndpoint is returned if no endpoint with the specified id exists
  27. type ErrNoEndpoint string
  28. func (ene ErrNoEndpoint) Error() string {
  29. return fmt.Sprintf("No endpoint (%s) exists", string(ene))
  30. }
  31. // NotFound denotes the type of this error
  32. func (ene ErrNoEndpoint) NotFound() {}
  33. // ErrActiveRegistration represents an error when a driver is registered to a networkType that is previously registered
  34. type ErrActiveRegistration string
  35. // Error interface for ErrActiveRegistration
  36. func (ar ErrActiveRegistration) Error() string {
  37. return fmt.Sprintf("Driver already registered for type %q", string(ar))
  38. }
  39. // Forbidden denotes the type of this error
  40. func (ar ErrActiveRegistration) Forbidden() {}