error.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #
  2. # Copyright 2018-2022 Elyra Authors
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. #
  16. """This module includes custom error classes pertaining to the metadata service."""
  17. class MetadataNotFoundError(Exception):
  18. """Raised when a metadata instance is not found.
  19. Overrides FileNotFoundError to set contextual message text
  20. and includes the corresponding schemaspace.
  21. """
  22. def __init__(self, schemaspace: str, name: str):
  23. super().__init__(f"No such instance named '{name}' was found in the {schemaspace} schemaspace.")
  24. class MetadataExistsError(Exception):
  25. """Raised when a metadata instance unexpectedly exists.
  26. Overrides FileExistsError to set contextual message text
  27. and includes the corresponding schemaspace.
  28. """
  29. def __init__(self, schemaspace: str, name: str):
  30. super().__init__(f"An instance named '{name}' already exists in the {schemaspace} schemaspace.")
  31. class SchemaNotFoundError(Exception):
  32. """Raised when a schema instance is not found.
  33. Overrides FileNotFoundError to set contextual message text
  34. and includes the corresponding schemaspace.
  35. """
  36. def __init__(self, schemaspace: str, name: str):
  37. super().__init__(f"No such schema named '{name}' was found in the {schemaspace} schemaspace.")