Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- Updated Google CSP domains
- Switched to checking response codes from `requests` in `SimpleJsonApiClient`

### Deprecated

Expand Down
37 changes: 22 additions & 15 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions tna_utilities/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,17 +160,17 @@ def _handle_response(self, response: Response) -> dict:
return response.json()
except JSONDecodeError:
raise Exception("Non-JSON response provided")
if response.status_code == 400:
if response.status_code == codes.bad_request:
try:
error_body = response.json()
except JSONDecodeError:
error_body = response.text
raise Exception(f"Bad request: {error_body}")
if response.status_code == 401:
if response.status_code == codes.unauthorized:
raise ResourceUnauthorized("Unauthorized")
if response.status_code == 403:
if response.status_code == codes.forbidden:
raise ResourceForbidden("Forbidden")
if response.status_code == 404:
if response.status_code == codes.not_found:
raise ResourceNotFound("Resource not found")
body_preview = (response.text or "").strip()
if body_preview:
Expand Down
Loading