schemas_exceptions.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. # Copyright 2016 Cloudbase Solutions Srl
  2. # All Rights Reserved.
  3. """ Defines a set of exceptions possible during schema loading/validation. """
  4. import jinja2
  5. import jsonschema
  6. from coriolis import exception
  7. class CoriolisSchemaException(exception.CoriolisException):
  8. """ Base class for all coriolis schema handling exceptions. """
  9. message = "Exception occured during schema validation: %(msg)s."
  10. class CoriolisSchemaValidationError(
  11. CoriolisSchemaException, jsonschema.ValidationError):
  12. """ Raised when a schema validation has failed. """
  13. message = "Failed to validate JSON schema: %(msg)s."
  14. class CoriolisSchemaParsingError(
  15. CoriolisSchemaException, ValueError):
  16. """ Raised when decoding of either the JSON schema or the JSON value being
  17. validated occurs.
  18. """
  19. message = "Failed to parse JSON for schema validation: %(msg)s."
  20. class CoriolisSchemaLoadingException(
  21. CoriolisSchemaException, jinja2.TemplateNotFound):
  22. """ Raised when schema files are not found. """
  23. message = "Failed to load schema: %(msg)s."