schemas_exceptions.py 1.0 KB

1234567891011121314151617181920212223242526272829303132
  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 a JSON schema or when validating a JSON value."""
  17. message = "Failed to parse JSON for schema validation: %(msg)s."
  18. class CoriolisSchemaLoadingException(
  19. CoriolisSchemaException, jinja2.TemplateNotFound):
  20. """Raised when schema files are not found."""
  21. message = "Failed to load schema: %(msg)s."