Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/pyasn1/error.py: 67%

18 statements  

« prev     ^ index     » next       coverage.py v7.3.2, created at 2023-12-08 06:51 +0000

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 

8 

9class PyAsn1Error(Exception): 

10 """Base pyasn1 exception 

11 

12 `PyAsn1Error` is the base exception class (based on 

13 :class:`Exception`) that represents all possible ASN.1 related 

14 errors. 

15 

16 Parameters 

17 ---------- 

18 args: 

19 Opaque positional parameters 

20 

21 Keyword Args 

22 ------------ 

23 kwargs: 

24 Opaque keyword parameters 

25 

26 """ 

27 def __init__(self, *args, **kwargs): 

28 self._args = args 

29 self._kwargs = kwargs 

30 

31 @property 

32 def context(self): 

33 """Return exception context 

34 

35 When exception object is created, the caller can supply some opaque 

36 context for the upper layers to better understand the cause of the 

37 exception. 

38 

39 Returns 

40 ------- 

41 : :py:class:`dict` 

42 Dict holding context specific data 

43 """ 

44 return self._kwargs.get('context', {}) 

45 

46 

47class ValueConstraintError(PyAsn1Error): 

48 """ASN.1 type constraints violation exception 

49 

50 The `ValueConstraintError` exception indicates an ASN.1 value 

51 constraint violation. 

52 

53 It might happen on value object instantiation (for scalar types) or on 

54 serialization (for constructed types). 

55 """ 

56 

57 

58class SubstrateUnderrunError(PyAsn1Error): 

59 """ASN.1 data structure deserialization error 

60 

61 The `SubstrateUnderrunError` exception indicates insufficient serialised 

62 data on input of a de-serialization codec. 

63 """ 

64 

65 

66class EndOfStreamError(SubstrateUnderrunError): 

67 """ASN.1 data structure deserialization error 

68 

69 The `EndOfStreamError` exception indicates the condition of the input 

70 stream has been closed. 

71 """ 

72 

73 

74class UnsupportedSubstrateError(PyAsn1Error): 

75 """Unsupported substrate type to parse as ASN.1 data.""" 

76 

77 

78class PyAsn1UnicodeError(PyAsn1Error, UnicodeError): 

79 """Unicode text processing error 

80 

81 The `PyAsn1UnicodeError` exception is a base class for errors relating to 

82 unicode text de/serialization. 

83 

84 Apart from inheriting from :class:`PyAsn1Error`, it also inherits from 

85 :class:`UnicodeError` to help the caller catching unicode-related errors. 

86 """ 

87 def __init__(self, message, unicode_error=None): 

88 if isinstance(unicode_error, UnicodeError): 

89 UnicodeError.__init__(self, *unicode_error.args) 

90 PyAsn1Error.__init__(self, message) 

91 

92 

93class PyAsn1UnicodeDecodeError(PyAsn1UnicodeError, UnicodeDecodeError): 

94 """Unicode text decoding error 

95 

96 The `PyAsn1UnicodeDecodeError` exception represents a failure to 

97 deserialize unicode text. 

98 

99 Apart from inheriting from :class:`PyAsn1UnicodeError`, it also inherits 

100 from :class:`UnicodeDecodeError` to help the caller catching unicode-related 

101 errors. 

102 """ 

103 

104 

105class PyAsn1UnicodeEncodeError(PyAsn1UnicodeError, UnicodeEncodeError): 

106 """Unicode text encoding error 

107 

108 The `PyAsn1UnicodeEncodeError` exception represents a failure to 

109 serialize unicode text. 

110 

111 Apart from inheriting from :class:`PyAsn1UnicodeError`, it also inherits 

112 from :class:`UnicodeEncodeError` to help the caller catching 

113 unicode-related errors. 

114 """ 

115 

116