-
-
Notifications
You must be signed in to change notification settings - Fork 492
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
Handle client errors in the requestStream method using ResponseClientException #90
Handle client errors in the requestStream method using ResponseClientException #90
Conversation
Hi @IshtarStar I think now I may get it, what the cause of our confusion is. Is it possible that you are not using Guzzle as the HTTP client? Because Guzzle does already throw an exception if the status code is 4xx. |
Hi @gehrisandro. I use the I added the guzzle RequestException to the catch and a third test. This way the requestStream response should work as expected independently from the client. |
Thank you for clarifying which client you are using. It looks like Guzzle does not respect the PSR-18 standard properly as it should not throw an exception in case of a 4xx status code: https://www.php-fig.org/psr/psr-18/#error-handling In my opinion your approach is not too bad but we should not throw different exceptions depending on the HTTP client used. Therefore I would prefer to throw the existing What do you think? |
I have adjusted it so that the TransporterException is thrown, independent of the client. |
Thank you for the update. Now it is a breaking change on the If you want me to have a closer look I can do this later this week. |
@gehrisandro Yes, let's find a solution that you think is appropriate. I know how many users already rely on this exception that it really becomes a breaching change. If you find time, feel free to look over it for your own way. |
I did a deeper research on the topic and I think we should unify the exception handling instead of just "fixing" the stream requests: #113 @IshtarStar This would solve your issue too? Right? |
This pull request introduces changes to the requestStream method to handle client errors in the 400 range by using a response exception class ResponseClientException that implements the ClientExceptionInterface. This ensures proper error handling while maintaining compatibility with the required interface.
Changes in this PR include:
With these changes, client errors in the 400 range are properly handled, making the requestStream method more robust and reliable.