@@ -109,16 +109,15 @@ def perform_request(self, method, url, params=None, body=None, timeout=None, ign
109109 response = self .pool .urlopen (method , url , body , retries = False , headers = self .headers , ** kw )
110110 duration = time .time () - start
111111 raw_data = response .data .decode ('utf-8' )
112- except UrllibSSLError as e :
113- self .log_request_fail (method , full_url , url , body , time .time () - start , exception = e )
114- raise SSLError ('N/A' , str (e ), e )
115- except ReadTimeoutError as e :
116- self .log_request_fail (method , full_url , url , body , time .time () - start , exception = e )
117- raise ConnectionTimeout ('TIMEOUT' , str (e ), e )
118112 except Exception as e :
119113 self .log_request_fail (method , full_url , url , body , time .time () - start , exception = e )
114+ if isinstance (e , UrllibSSLError ):
115+ raise SSLError ('N/A' , str (e ), e )
116+ if isinstance (e , ReadTimeoutError ):
117+ raise ConnectionTimeout ('TIMEOUT' , str (e ), e )
120118 raise ConnectionError ('N/A' , str (e ), e )
121119
120+ # raise errors based on http status codes, let the client handle those if needed
122121 if not (200 <= response .status < 300 ) and response .status not in ignore :
123122 self .log_request_fail (method , full_url , url , body , duration , response .status , raw_data )
124123 self ._raise_error (response .status , raw_data )
0 commit comments