Resolving Variable Reference Error (#2903)

This commit is contained in:
Noah McGregor Harper
2023-03-02 20:44:49 +00:00
committed by GitHub
parent f12319b359
commit e653f9b73e

View File

@ -415,17 +415,16 @@ class Backend:
if response.status_code // 100 != 2: if response.status_code // 100 != 2:
try: try:
json = response.json() json = response.json()
# attempt to read as https://www.rfc-editor.org/rfc/rfc7807
if isinstance(json, Dict):
title = json.get("title")
details = json.get("detail")
raise Exception(
f"request did not succeed ({response.status_code}: {title}): {details}"
)
except requests.exceptions.JSONDecodeError: except requests.exceptions.JSONDecodeError:
pass pass
# attempt to read as https://www.rfc-editor.org/rfc/rfc7807
if isinstance(json, Dict):
title = json.get("title")
details = json.get("detail")
raise Exception(
f"request did not succeed ({response.status_code}: {title}): {details}"
)
error_text = str( error_text = str(
response.content, encoding="utf-8", errors="backslashreplace" response.content, encoding="utf-8", errors="backslashreplace"
) )