Funktionierender Prototyp des Serious Games zur Vermittlung von Wissen zu Software-Engineering-Arbeitsmodellen.
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 3.2KB

1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #
  2. # This file is part of pyasn1 software.
  3. #
  4. # Copyright (c) 2005-2020, Ilya Etingof <etingof@gmail.com>
  5. # License: https://pyasn1.readthedocs.io/en/latest/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. Parameters
  13. ----------
  14. args:
  15. Opaque positional parameters
  16. Keyword Args
  17. ------------
  18. kwargs:
  19. Opaque keyword parameters
  20. """
  21. def __init__(self, *args, **kwargs):
  22. self._args = args
  23. self._kwargs = kwargs
  24. @property
  25. def context(self):
  26. """Return exception context
  27. When exception object is created, the caller can supply some opaque
  28. context for the upper layers to better understand the cause of the
  29. exception.
  30. Returns
  31. -------
  32. : :py:class:`dict`
  33. Dict holding context specific data
  34. """
  35. return self._kwargs.get('context', {})
  36. class ValueConstraintError(PyAsn1Error):
  37. """ASN.1 type constraints violation exception
  38. The `ValueConstraintError` exception indicates an ASN.1 value
  39. constraint violation.
  40. It might happen on value object instantiation (for scalar types) or on
  41. serialization (for constructed types).
  42. """
  43. class SubstrateUnderrunError(PyAsn1Error):
  44. """ASN.1 data structure deserialization error
  45. The `SubstrateUnderrunError` exception indicates insufficient serialised
  46. data on input of a de-serialization codec.
  47. """
  48. class EndOfStreamError(SubstrateUnderrunError):
  49. """ASN.1 data structure deserialization error
  50. The `EndOfStreamError` exception indicates the condition of the input
  51. stream has been closed.
  52. """
  53. class UnsupportedSubstrateError(PyAsn1Error):
  54. """Unsupported substrate type to parse as ASN.1 data."""
  55. class PyAsn1UnicodeError(PyAsn1Error, UnicodeError):
  56. """Unicode text processing error
  57. The `PyAsn1UnicodeError` exception is a base class for errors relating to
  58. unicode text de/serialization.
  59. Apart from inheriting from :class:`PyAsn1Error`, it also inherits from
  60. :class:`UnicodeError` to help the caller catching unicode-related errors.
  61. """
  62. def __init__(self, message, unicode_error=None):
  63. if isinstance(unicode_error, UnicodeError):
  64. UnicodeError.__init__(self, *unicode_error.args)
  65. PyAsn1Error.__init__(self, message)
  66. class PyAsn1UnicodeDecodeError(PyAsn1UnicodeError, UnicodeDecodeError):
  67. """Unicode text decoding error
  68. The `PyAsn1UnicodeDecodeError` exception represents a failure to
  69. deserialize unicode text.
  70. Apart from inheriting from :class:`PyAsn1UnicodeError`, it also inherits
  71. from :class:`UnicodeDecodeError` to help the caller catching unicode-related
  72. errors.
  73. """
  74. class PyAsn1UnicodeEncodeError(PyAsn1UnicodeError, UnicodeEncodeError):
  75. """Unicode text encoding error
  76. The `PyAsn1UnicodeEncodeError` exception represents a failure to
  77. serialize unicode text.
  78. Apart from inheriting from :class:`PyAsn1UnicodeError`, it also inherits
  79. from :class:`UnicodeEncodeError` to help the caller catching
  80. unicode-related errors.
  81. """