feat: implement exceptions and error handling#101
Open
Stasky745 wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Solves #99
What changed
The SDK was silently discarding HTTP response metadata — callers received only the JSON body and had no way to access the status code or detect errors. A 404 or 500 response would be returned as a plain dict, indistinguishable from a successful response.
Core fix
Added
response.raise_for_status()inApiClient.request()before returning. This single change means any 4xx or 5xx response now raisesrequests.HTTPErrorinstead of being silently passed through. The exception carries the full response, so callers can still inspect the status code and error body when needed:SDK method cleanup
With errors now handled centrally, all manual status code checks across the SDK were simplified:
True if response.status_code == 204 else Falsenow just returnTrue— theFalsebranch is unreachable since a non-204 raises before itsubscribers.delete()andsubscribers.forget()were returning raw status code integers (204,200) — changed to returnTruefor consistencyTest updates
pytest.raises(requests.HTTPError)— this is what actually happens now, and it's the correct behaviour== 204,== 200) updated tois TrueBonus fix
Removed a stray
print(query_params)debug statement left inautomations.list().