errors.go 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. package cluster
  2. const (
  3. // errNoSwarm is returned on leaving a cluster that was never initialized
  4. errNoSwarm notAvailableError = "This node is not part of a swarm"
  5. // errSwarmExists is returned on initialize or join request for a cluster that has already been activated
  6. errSwarmExists notAvailableError = "This node is already part of a swarm. Use \"docker swarm leave\" to leave this swarm and join another one."
  7. // errSwarmJoinTimeoutReached is returned when cluster join could not complete before timeout was reached.
  8. errSwarmJoinTimeoutReached notAvailableError = "Timeout was reached before node joined. The attempt to join the swarm will continue in the background. Use the \"docker info\" command to see the current swarm status of your node."
  9. // errSwarmLocked is returned if the swarm is encrypted and needs a key to unlock it.
  10. errSwarmLocked notAvailableError = "Swarm is encrypted and needs to be unlocked before it can be used. Please use \"docker swarm unlock\" to unlock it."
  11. // errSwarmCertificatesExpired is returned if docker was not started for the whole validity period and they had no chance to renew automatically.
  12. errSwarmCertificatesExpired notAvailableError = "Swarm certificates have expired. To replace them, leave the swarm and join again."
  13. // errSwarmNotManager is returned if the node is not a swarm manager.
  14. errSwarmNotManager notAvailableError = "This node is not a swarm manager. Worker nodes can't be used to view or modify cluster state. Please run this command on a manager node or promote the current node to a manager."
  15. )
  16. type notFoundError struct {
  17. cause error
  18. }
  19. func (e notFoundError) Error() string {
  20. return e.cause.Error()
  21. }
  22. func (e notFoundError) NotFound() {}
  23. func (e notFoundError) Cause() error {
  24. return e.cause
  25. }
  26. type ambiguousResultsError struct {
  27. cause error
  28. }
  29. func (e ambiguousResultsError) Error() string {
  30. return e.cause.Error()
  31. }
  32. func (e ambiguousResultsError) InvalidParameter() {}
  33. func (e ambiguousResultsError) Cause() error {
  34. return e.cause
  35. }
  36. type convertError struct {
  37. cause error
  38. }
  39. func (e convertError) Error() string {
  40. return e.cause.Error()
  41. }
  42. func (e convertError) InvalidParameter() {}
  43. func (e convertError) Cause() error {
  44. return e.cause
  45. }
  46. type notAllowedError string
  47. func (e notAllowedError) Error() string {
  48. return string(e)
  49. }
  50. func (e notAllowedError) Forbidden() {}
  51. type validationError struct {
  52. cause error
  53. }
  54. func (e validationError) Error() string {
  55. return e.cause.Error()
  56. }
  57. func (e validationError) InvalidParameter() {}
  58. func (e validationError) Cause() error {
  59. return e.cause
  60. }
  61. type notAvailableError string
  62. func (e notAvailableError) Error() string {
  63. return string(e)
  64. }
  65. func (e notAvailableError) Unavailable() {}
  66. type configError string
  67. func (e configError) Error() string {
  68. return string(e)
  69. }
  70. func (e configError) InvalidParameter() {}
  71. type invalidUnlockKey struct{}
  72. func (invalidUnlockKey) Error() string {
  73. return "swarm could not be unlocked: invalid key provided"
  74. }
  75. func (invalidUnlockKey) Unauthorized() {}
  76. type notLockedError struct{}
  77. func (notLockedError) Error() string {
  78. return "swarm is not locked"
  79. }
  80. func (notLockedError) Conflict() {}