exceptions.py 871 B

12345678910111213141516171819202122232425262728
  1. class ProfileNotFound(Exception):
  2. def __init__(self, name, profile_path):
  3. super().__init__()
  4. self.name = name
  5. self.profile_path = profile_path
  6. def __repr__(self):
  7. return "Could not find profile {}; searched in {}".format(
  8. self.name,
  9. ":".join(self.profile_path),
  10. )
  11. class CannotParseProfile(Exception):
  12. def __init__(self, filepath, parse_error):
  13. super().__init__()
  14. self.filepath = filepath
  15. self.parse_error = parse_error
  16. def get_parse_message(self):
  17. return "{}\n on line {} : char {}".format(
  18. self.parse_error.problem,
  19. self.parse_error.problem_mark.line,
  20. self.parse_error.problem_mark.column,
  21. )
  22. def __repr__(self):
  23. return "Could not parse profile found at %s - it is not valid YAML" % self.filepath