diff options
Diffstat (limited to 'pyasn1/error.py')
-rw-r--r-- | pyasn1/error.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/pyasn1/error.py b/pyasn1/error.py index 85a31ff..08ec1b3 100644 --- a/pyasn1/error.py +++ b/pyasn1/error.py @@ -12,7 +12,36 @@ class PyAsn1Error(Exception): `PyAsn1Error` is the base exception class (based on :class:`Exception`) that represents all possible ASN.1 related errors. + + Parameters + ---------- + args: + Opaque positional parameters + + Keyword Args + ------------ + kwargs: + Opaque keyword parameters + """ + def __init__(self, *args, **kwargs): + self._args = args + self._kwargs = kwargs + + @property + def context(self): + """Return exception context + + When exception object is created, the caller can supply some opaque + context for the upper layers to better understand the cause of the + exception. + + Returns + ------- + : :py:class:`dict` + Dict holding context specific data + """ + return self._kwargs.get('context', {}) class ValueConstraintError(PyAsn1Error): @@ -34,6 +63,14 @@ class SubstrateUnderrunError(PyAsn1Error): """ +class EndOfStreamError(SubstrateUnderrunError): + """ASN.1 data structure deserialization error + + The `EndOfStreamError` exception indicates the condition of the input + stream has been closed. + """ + + class UnsupportedSubstrateError(PyAsn1Error): """Unsupported substrate type to parse as ASN.1 data.""" |