exceptions.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. from gssapi.raw.exceptions import * # noqa
  2. from gssapi.raw.misc import GSSError # noqa
  3. """High-Level API Errors
  4. This module includes several high-level exceptions,
  5. in addition to GSSError and exceptions from
  6. :mod:`gssapi.raw.exceptions`.
  7. """
  8. # non-GSS exceptions
  9. class GeneralError(Exception):
  10. """A General High-Level API Error"""
  11. MAJOR_MESSAGE = "General error"
  12. FMT_STR = "{maj}: {min}."
  13. def __init__(self, minor_message, **kwargs):
  14. maj_str = self.MAJOR_MESSAGE.format(**kwargs)
  15. err_str = self.FMT_STR.format(maj=maj_str, min=minor_message)
  16. super(GeneralError, self).__init__(err_str)
  17. class UnknownUsageError(GeneralError):
  18. """An Error indicating an unknown usage type"""
  19. MAJOR_MESSAGE = "Unable to determine {obj} usage"
  20. class EncryptionNotUsed(GeneralError):
  21. """An Error indicating that encryption was requested, but not used"""
  22. MAJOR_MESSAGE = "Confidentiality was requested, but not used"
  23. def __init__(self, minor_message, unwrapped_message=None, **kwargs):
  24. super(EncryptionNotUsed, self).__init__(minor_message, **kwargs)
  25. self.unwrapped_message = unwrapped_message