|
if response.status_code == 401: |
|
raise Sindri.APIError(f"401 - Invalid API Key. path={full_path}") |
|
elif response.status_code == 404: |
|
raise Sindri.APIError(f"404 - Not found. path={full_path}") |
|
else: |
|
# Decode JSON response |
|
try: |
|
response_json = response.json() |
|
except json.decoder.JSONDecodeError: |
|
raise Sindri.APIError( |
|
f"Unexpected Error. Unable to decode response as JSON." |
|
f" status={response.status_code} response={response.text}" |
|
) from None |
|
return response.status_code, response_json |
Raise an APIError for all error status codes
Issue: Not all error status codes raise an exception with the status_code number in the exception string. This leads to silent failures.
Resolution: Adjust the conditional logic (linked above) to always raise an APIError with the status_code if there is an error, not just if the response cannot be decoded from JSON.
sindri-python/src/sindri/sindri.py
Lines 316 to 329 in ba0200c
Raise an APIError for all error status codes
Issue: Not all error status codes raise an exception with the status_code number in the exception string. This leads to silent failures.
Resolution: Adjust the conditional logic (linked above) to always raise an APIError with the status_code if there is an error, not just if the response cannot be decoded from JSON.