exception.py 804 B

123456789101112131415161718192021222324252627
  1. ### IMPORTS
  2. ### ============================================================================
  3. ## Future
  4. from __future__ import annotations
  5. ## Standard Library
  6. ## Installed
  7. ## Application
  8. ### CLASSES
  9. ### ============================================================================
  10. class PythonJsonLoggerError(Exception):
  11. "Generic base clas for all Python JSON Logger exceptions"
  12. class MissingPackageError(ImportError, PythonJsonLoggerError):
  13. "A required package is missing"
  14. def __init__(self, name: str, extras_name: str | None = None) -> None:
  15. msg = f"The {name!r} package is required but could not be found."
  16. if extras_name is not None:
  17. msg += f" It can be installed using 'python-json-logger[{extras_name}]'."
  18. super().__init__(msg)
  19. return