PTHMINT-131: Add error handling for transport exceptions and server e…#68
Open
zulquer wants to merge 2 commits into
Open
PTHMINT-131: Add error handling for transport exceptions and server e…#68zulquer wants to merge 2 commits into
zulquer wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR strengthens Client._create_request error handling when the underlying transport fails before producing a response object, and adds unit tests to cover both “no response” transport failures and HTTP 5xx server-error wrapping into ApiException.
Changes:
- Initialize
response = Nonein_create_requestand guard access toresponse.status_codeto avoid errors when the transport raises before returning a response. - Add transport/response test stubs to simulate network failures and 5xx responses.
- Add unit tests for re-raising transport exceptions without a response, and wrapping 5xx errors into
ApiException.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/multisafepay/client/client.py |
Prevents referencing response when transport fails before returning one; wraps 5xx failures as ApiException. |
tests/multisafepay/unit/client/test_unit_client.py |
Adds unit coverage for transport exceptions without a response and for 5xx server error wrapping. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+378
to
+379
| with pytest.raises(ApiException, match="Request failed: server error"): | ||
| client.create_get_request("json/orders") |
danielcivit
requested changes
Jul 7, 2026
Member
There was a problem hiding this comment.
Test are failing. Please check the details and part of these changes were already merged here: #65
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.
This pull request improves error handling in the
Clientclass and adds comprehensive unit tests to ensure correct behavior when network errors or server errors occur. The main changes focus on making exception handling more robust and well-tested.Error handling improvements:
_create_requestinclient.pyto initializeresponsetoNoneand check forresponse is not Nonebefore accessing its attributes, preventing errors when the transport fails before returning a response. [1] [2]Testing enhancements:
_FailingTransport,_ServerErrorTransport,_ServerErrorResponse) to simulate network failures and server errors, enabling more thorough testing of error handling logic in theClient.ApiException.ApiExceptionin the test module to support the new tests.…rrors in Client