Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/botocore/vendored/requests/packages/urllib3/exceptions.py: 85%

67 statements  

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

1 

2## Base Exceptions 

3 

4class HTTPError(Exception): 

5 "Base exception used by this module." 

6 pass 

7 

8class HTTPWarning(Warning): 

9 "Base warning used by this module." 

10 pass 

11 

12 

13 

14class PoolError(HTTPError): 

15 "Base exception for errors caused within a pool." 

16 def __init__(self, pool, message): 

17 self.pool = pool 

18 HTTPError.__init__(self, "%s: %s" % (pool, message)) 

19 

20 def __reduce__(self): 

21 # For pickling purposes. 

22 return self.__class__, (None, None) 

23 

24 

25class RequestError(PoolError): 

26 "Base exception for PoolErrors that have associated URLs." 

27 def __init__(self, pool, url, message): 

28 self.url = url 

29 PoolError.__init__(self, pool, message) 

30 

31 def __reduce__(self): 

32 # For pickling purposes. 

33 return self.__class__, (None, self.url, None) 

34 

35 

36class SSLError(HTTPError): 

37 "Raised when SSL certificate fails in an HTTPS connection." 

38 pass 

39 

40 

41class ProxyError(HTTPError): 

42 "Raised when the connection to a proxy fails." 

43 pass 

44 

45 

46class DecodeError(HTTPError): 

47 "Raised when automatic decoding based on Content-Type fails." 

48 pass 

49 

50 

51class ProtocolError(HTTPError): 

52 "Raised when something unexpected happens mid-request/response." 

53 pass 

54 

55 

56#: Renamed to ProtocolError but aliased for backwards compatibility. 

57ConnectionError = ProtocolError 

58 

59 

60## Leaf Exceptions 

61 

62class MaxRetryError(RequestError): 

63 """Raised when the maximum number of retries is exceeded. 

64 

65 :param pool: The connection pool 

66 :type pool: :class:`~urllib3.connectionpool.HTTPConnectionPool` 

67 :param string url: The requested Url 

68 :param exceptions.Exception reason: The underlying error 

69 

70 """ 

71 

72 def __init__(self, pool, url, reason=None): 

73 self.reason = reason 

74 

75 message = "Max retries exceeded with url: %s (Caused by %r)" % ( 

76 url, reason) 

77 

78 RequestError.__init__(self, pool, url, message) 

79 

80 

81class HostChangedError(RequestError): 

82 "Raised when an existing pool gets a request for a foreign host." 

83 

84 def __init__(self, pool, url, retries=3): 

85 message = "Tried to open a foreign host with url: %s" % url 

86 RequestError.__init__(self, pool, url, message) 

87 self.retries = retries 

88 

89 

90class TimeoutStateError(HTTPError): 

91 """ Raised when passing an invalid state to a timeout """ 

92 pass 

93 

94 

95class TimeoutError(HTTPError): 

96 """ Raised when a socket timeout error occurs. 

97 

98 Catching this error will catch both :exc:`ReadTimeoutErrors 

99 <ReadTimeoutError>` and :exc:`ConnectTimeoutErrors <ConnectTimeoutError>`. 

100 """ 

101 pass 

102 

103 

104class ReadTimeoutError(TimeoutError, RequestError): 

105 "Raised when a socket timeout occurs while receiving data from a server" 

106 pass 

107 

108 

109# This timeout error does not have a URL attached and needs to inherit from the 

110# base HTTPError 

111class ConnectTimeoutError(TimeoutError): 

112 "Raised when a socket timeout occurs while connecting to a server" 

113 pass 

114 

115 

116class EmptyPoolError(PoolError): 

117 "Raised when a pool runs out of connections and no more are allowed." 

118 pass 

119 

120 

121class ClosedPoolError(PoolError): 

122 "Raised when a request enters a pool after the pool has been closed." 

123 pass 

124 

125 

126class LocationValueError(ValueError, HTTPError): 

127 "Raised when there is something wrong with a given URL input." 

128 pass 

129 

130 

131class LocationParseError(LocationValueError): 

132 "Raised when get_host or similar fails to parse the URL input." 

133 

134 def __init__(self, location): 

135 message = "Failed to parse: %s" % location 

136 HTTPError.__init__(self, message) 

137 

138 self.location = location 

139 

140 

141class ResponseError(HTTPError): 

142 "Used as a container for an error reason supplied in a MaxRetryError." 

143 GENERIC_ERROR = 'too many error responses' 

144 SPECIFIC_ERROR = 'too many {status_code} error responses' 

145 

146 

147class SecurityWarning(HTTPWarning): 

148 "Warned when perfoming security reducing actions" 

149 pass 

150 

151 

152class InsecureRequestWarning(SecurityWarning): 

153 "Warned when making an unverified HTTPS request." 

154 pass 

155 

156 

157class SystemTimeWarning(SecurityWarning): 

158 "Warned when system time is suspected to be wrong" 

159 pass 

160 

161 

162class InsecurePlatformWarning(SecurityWarning): 

163 "Warned when certain SSL configuration is not available on a platform." 

164 pass 

165 

166 

167class ResponseNotChunked(ProtocolError, ValueError): 

168 "Response needs to be chunked in order to read it as chunks." 

169 pass