Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/oscrypto/errors.py: 72%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

39 statements  

1# coding: utf-8 

2from __future__ import unicode_literals, division, absolute_import, print_function 

3 

4import sys 

5import socket 

6 

7 

8__all__ = [ 

9 'AsymmetricKeyError', 

10 'CACertsError', 

11 'LibraryNotFoundError', 

12 'SignatureError', 

13 'TLSError', 

14 'TLSConnectionError', 

15 'TLSDisconnectError', 

16 'TLSGracefulDisconnectError', 

17 'TLSVerificationError', 

18] 

19 

20 

21class LibraryNotFoundError(Exception): 

22 

23 """ 

24 An exception when trying to find a shared library 

25 """ 

26 

27 pass 

28 

29 

30class SignatureError(Exception): 

31 

32 """ 

33 An exception when validating a signature 

34 """ 

35 

36 pass 

37 

38 

39class AsymmetricKeyError(Exception): 

40 

41 """ 

42 An exception when a key is invalid or unsupported 

43 """ 

44 

45 pass 

46 

47 

48class IncompleteAsymmetricKeyError(AsymmetricKeyError): 

49 

50 """ 

51 An exception when a key is missing necessary information 

52 """ 

53 

54 pass 

55 

56 

57class CACertsError(Exception): 

58 

59 """ 

60 An exception when exporting CA certs from the OS trust store 

61 """ 

62 

63 pass 

64 

65 

66class TLSError(socket.error): 

67 

68 """ 

69 An exception related to TLS functionality 

70 """ 

71 

72 message = None 

73 

74 def __init__(self, message): 

75 self.args = (message,) 

76 self.message = message 

77 

78 def __str__(self): 

79 output = self.__unicode__() 

80 if sys.version_info < (3,): 

81 output = output.encode('utf-8') 

82 return output 

83 

84 def __unicode__(self): 

85 return self.message 

86 

87 

88class TLSConnectionError(TLSError): 

89 pass 

90 

91 

92class TLSDisconnectError(TLSConnectionError): 

93 pass 

94 

95 

96class TLSGracefulDisconnectError(TLSDisconnectError): 

97 pass 

98 

99 

100class TLSVerificationError(TLSError): 

101 

102 """ 

103 A server certificate verification error happened during a TLS handshake 

104 """ 

105 

106 certificate = None 

107 

108 def __init__(self, message, certificate): 

109 TLSError.__init__(self, message) 

110 self.certificate = certificate 

111 self.args = (message, certificate)