errors.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. from __future__ import absolute_import
  2. from __future__ import unicode_literals
  3. from textwrap import dedent
  4. class UserError(Exception):
  5. def __init__(self, msg):
  6. self.msg = dedent(msg).strip()
  7. def __unicode__(self):
  8. return self.msg
  9. __str__ = __unicode__
  10. class DockerNotFoundMac(UserError):
  11. def __init__(self):
  12. super(DockerNotFoundMac, self).__init__("""
  13. Couldn't connect to Docker daemon. You might need to install docker-osx:
  14. https://github.com/noplay/docker-osx
  15. """)
  16. class DockerNotFoundUbuntu(UserError):
  17. def __init__(self):
  18. super(DockerNotFoundUbuntu, self).__init__("""
  19. Couldn't connect to Docker daemon. You might need to install Docker:
  20. https://docs.docker.com/engine/installation/ubuntulinux/
  21. """)
  22. class DockerNotFoundGeneric(UserError):
  23. def __init__(self):
  24. super(DockerNotFoundGeneric, self).__init__("""
  25. Couldn't connect to Docker daemon. You might need to install Docker:
  26. https://docs.docker.com/engine/installation/
  27. """)
  28. class ConnectionErrorDockerMachine(UserError):
  29. def __init__(self):
  30. super(ConnectionErrorDockerMachine, self).__init__("""
  31. Couldn't connect to Docker daemon - you might need to run `docker-machine start default`.
  32. """)
  33. class ConnectionErrorGeneric(UserError):
  34. def __init__(self, url):
  35. super(ConnectionErrorGeneric, self).__init__("""
  36. Couldn't connect to Docker daemon at %s - is it running?
  37. If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
  38. """ % url)