errors.py 1.7 KB

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