1
0

errors.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. from __future__ import absolute_import
  2. from __future__ import unicode_literals
  3. VERSION_EXPLANATION = (
  4. 'You might be seeing this error because you\'re using the wrong Compose file version. '
  5. 'Either specify a supported version ("2.0", "2.1", "3.0") and place your '
  6. 'service definitions under the `services` key, or omit the `version` key '
  7. 'and place your service definitions at the root of the file to use '
  8. 'version 1.\nFor more on the Compose file format versions, see '
  9. 'https://docs.docker.com/compose/compose-file/')
  10. class ConfigurationError(Exception):
  11. def __init__(self, msg):
  12. self.msg = msg
  13. def __str__(self):
  14. return self.msg
  15. class DependencyError(ConfigurationError):
  16. pass
  17. class CircularReference(ConfigurationError):
  18. def __init__(self, trail):
  19. self.trail = trail
  20. @property
  21. def msg(self):
  22. lines = [
  23. "{} in {}".format(service_name, filename)
  24. for (filename, service_name) in self.trail
  25. ]
  26. return "Circular reference:\n {}".format("\n extends ".join(lines))
  27. class ComposeFileNotFound(ConfigurationError):
  28. def __init__(self, supported_filenames):
  29. super(ComposeFileNotFound, self).__init__("""
  30. Can't find a suitable configuration file in this directory or any
  31. parent. Are you in the right directory?
  32. Supported filenames: %s
  33. """ % ", ".join(supported_filenames))