@@ -11,21 +11,23 @@ def make_request(method: Method, url: str, **kwargs) -> Any:
1111 response = requests .request (method .value , url = url , ** kwargs )
1212 response .raise_for_status ()
1313 except requests .exceptions .RequestException as err :
14- response = err .response
14+ r = err .response
1515 if not err .response :
1616 # Connection errors, timepouts, etc...
17- raise BugoutResponseException ("Network error" , detail = str (err ))
18- if response .headers .get ("Content-Type" ) == "application/json" :
19- exception_detail = response .json ()["detail" ]
17+ raise BugoutResponseException (
18+ "Network error" , status_code = 599 , detail = str (err )
19+ )
20+ if r .headers .get ("Content-Type" ) == "application/json" :
21+ exception_detail = r .json ()["detail" ]
2022 else :
21- exception_detail = response .text
23+ exception_detail = r .text
2224 raise BugoutResponseException (
2325 "An exception occurred at Bugout API side" ,
24- status_code = response .status_code ,
26+ status_code = r .status_code ,
2527 detail = exception_detail ,
2628 )
2729 except Exception as e :
28- raise BugoutUnexpectedResponse ({ str (e )} )
30+ raise BugoutUnexpectedResponse (str (e ))
2931 return response .json ()
3032
3133
0 commit comments