Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ClientErrorResponseException for 4xx response codes #367

Merged
merged 3 commits into from
Jul 13, 2023

Conversation

rhertogh
Copy link
Contributor

Q A
Is bugfix?
New feature? ✔️
Breaks BC?
Fixed issues -

This PR allows to filter out client error response codes (4xx). E.g.

try {
    $client->api('https://test');
} catch (ClientErrorResponseException $e) {
    // Handle client error response
}

@what-the-diff
Copy link

what-the-diff bot commented Jul 12, 2023

PR Summary

  • Enhanced Error Handling in BaseOAuth
    The sendRequest() method in src/BaseOAuth.php has been revised to include more specific handling of different error types. This will provide clearer, more targeted error messages based on the type of error that occurred, which should result in easier troubleshooting and issue resolution.

  • New ClientErrorResponseException Class
    A new file, src/ClientErrorResponseException.php, has been added, which defines a distinct type of exception for "client errors". These are errors where the client sends a wrong or illegal request to the server.

  • Update in InvalidResponseException Class Description
    The description of the InvalidResponseException class in src/InvalidResponseException.php was clarified to specify that it pertains to non-successful server response codes. This provides clearer understanding about its functionality and usage.

  • Code Refinement in VKontakte
    In src/clients/VKontakte.php, an unnecessary use statement importing InvalidResponseException has been removed to streamline the code.

  • New Test Method for sendRequest()
    A new test method, testSendRequest(), has been added in tests/BaseOAuthTest.php to validate the functionality of the revised sendRequest() method in varied scenarios. This enhances the overall test coverage and ensures the reliability of error handling changes.

…sponseException` when the response code in `BaseOAuth::sendRequest()` is a 4xx)
…iscoverConfigCache()` InvalidResponseException test.
@rhertogh rhertogh marked this pull request as ready for review July 12, 2023 21:11
@rhertogh rhertogh requested a review from samdark July 12, 2023 21:11
@samdark samdark merged commit a98dbed into yiisoft:master Jul 13, 2023
9 checks passed
@samdark
Copy link
Member

samdark commented Jul 13, 2023

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants