You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

error.py 2.2KB

5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #
  2. # This file is part of pyasn1 software.
  3. #
  4. # Copyright (c) 2005-2019, Ilya Etingof <etingof@gmail.com>
  5. # License: http://snmplabs.com/pyasn1/license.html
  6. #
  7. class PyAsn1Error(Exception):
  8. """Base pyasn1 exception
  9. `PyAsn1Error` is the base exception class (based on
  10. :class:`Exception`) that represents all possible ASN.1 related
  11. errors.
  12. """
  13. class ValueConstraintError(PyAsn1Error):
  14. """ASN.1 type constraints violation exception
  15. The `ValueConstraintError` exception indicates an ASN.1 value
  16. constraint violation.
  17. It might happen on value object instantiation (for scalar types) or on
  18. serialization (for constructed types).
  19. """
  20. class SubstrateUnderrunError(PyAsn1Error):
  21. """ASN.1 data structure deserialization error
  22. The `SubstrateUnderrunError` exception indicates insufficient serialised
  23. data on input of a de-serialization codec.
  24. """
  25. class PyAsn1UnicodeError(PyAsn1Error, UnicodeError):
  26. """Unicode text processing error
  27. The `PyAsn1UnicodeError` exception is a base class for errors relating to
  28. unicode text de/serialization.
  29. Apart from inheriting from :class:`PyAsn1Error`, it also inherits from
  30. :class:`UnicodeError` to help the caller catching unicode-related errors.
  31. """
  32. def __init__(self, message, unicode_error=None):
  33. if isinstance(unicode_error, UnicodeError):
  34. UnicodeError.__init__(self, *unicode_error.args)
  35. PyAsn1Error.__init__(self, message)
  36. class PyAsn1UnicodeDecodeError(PyAsn1UnicodeError, UnicodeDecodeError):
  37. """Unicode text decoding error
  38. The `PyAsn1UnicodeDecodeError` exception represents a failure to
  39. deserialize unicode text.
  40. Apart from inheriting from :class:`PyAsn1UnicodeError`, it also inherits
  41. from :class:`UnicodeDecodeError` to help the caller catching unicode-related
  42. errors.
  43. """
  44. class PyAsn1UnicodeEncodeError(PyAsn1UnicodeError, UnicodeEncodeError):
  45. """Unicode text encoding error
  46. The `PyAsn1UnicodeEncodeError` exception represents a failure to
  47. serialize unicode text.
  48. Apart from inheriting from :class:`PyAsn1UnicodeError`, it also inherits
  49. from :class:`UnicodeEncodeError` to help the caller catching
  50. unicode-related errors.
  51. """