Skip to content

Commit

Permalink
fix: On a 500 status code do not try to read json
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr0p42 committed Feb 20, 2024
1 parent fc21971 commit d99f855
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions naas_python/utils/domains_base/secondary/BaseAPIAdaptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ def make_api_request(
return api_response

except requests.exceptions.HTTPError as e:
_response = api_response.json()
if api_response.status_code == 401:
_response = api_response.json()
_message = ""
if "error_message" in _response:
_message = _response["error_message"]
Expand All @@ -103,13 +103,7 @@ def make_api_request(
e,
)
elif api_response.status_code == 500:
_message = ""
if "error_message" in _response:
_message = _response["error_message"]
elif "detail" in _response:
_message = _response["detail"]
else:
_message = "Internal Server Error"
_message = "Internal Server Error"
raise ServiceStatusError(_message, e)
else:
# Other status codes will be handled by the calling method
Expand Down

0 comments on commit d99f855

Please sign in to comment.