22Exports the HTTP API class
33"""
44
5- import requests
5+ import aikido_zen . background_process . requests as requests
66from aikido_zen .background_process .api import ReportingApi
7+ from aikido_zen .background_process .requests .errors import TimeoutExceeded
78from aikido_zen .helpers .logging import logger
89
910
@@ -21,11 +22,10 @@ def report(self, token, event, timeout_in_sec):
2122 timeout = timeout_in_sec ,
2223 headers = get_headers (token ),
2324 )
24- except requests .exceptions .ConnectionError as e :
25- logger .error (e )
25+ except TimeoutExceeded as e :
2626 return {"success" : False , "error" : "timeout" }
2727 except Exception as e :
28- logger .error (e )
28+ logger .error ("Failed to report event : %s(%s)" , str ( e . __class__ ), str ( e ) )
2929 return {"success" : False , "error" : "unknown" }
3030 return self .to_api_response (res )
3131
@@ -47,11 +47,10 @@ def fetch_firewall_lists(self, token):
4747 "Authorization" : str (token ),
4848 },
4949 )
50- except requests .exceptions .ConnectionError as e :
51- logger .error (e )
50+ except TimeoutExceeded as e :
5251 return {"success" : False , "error" : "timeout" }
5352 except Exception as e :
54- logger .error (e )
53+ logger .error ("Failed to fetch firewall lists: %s" , str ( e ) )
5554 return {"success" : False , "error" : "unknown" }
5655 return self .to_api_response (res )
5756
0 commit comments