Skip to content

[HttpClient] better explain how to deal with exceptions #13136

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

Merged
merged 1 commit into from
Feb 15, 2020

Conversation

nicolas-grekas
Copy link
Member

Replaces #13078 and #13134

@mleczakm
Copy link
Contributor

Perfectly describes what really happens, definitely missing part of docs - 👍

Copy link
Contributor

@B-Galati B-Galati left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great!

} elseif ($chunk->isFirst()) {
// if you want to check the status code, you must do it when the
// first chunk arrived, using $response->getStatusCode();
// not doing so might trigger an HttpExceptionInterface
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the response headers might not be arrived yet? I am not sure to understand in which case it can happen.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It happens because that's how the first chunk behaves : if status code is unchecked after it, an exception is thrown. I'm going to improve this

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was a little bit confusing that the exception is thrown from the iterator(generator), so you can not catch it inside a for-each cycle and continue to process other requests.

javiereguiluz added a commit that referenced this pull request Feb 15, 2020
…(nicolas-grekas)

This PR was merged into the 4.4 branch.

Discussion
----------

[HttpClient] better explain how to deal with exceptions

Replaces #13078 and #13134

Commits
-------

61cddf5 [HttpClient] better explain how to deal with exceptions
@javiereguiluz javiereguiluz merged commit 61cddf5 into symfony:4.4 Feb 15, 2020
@javiereguiluz
Copy link
Member

Thanks Nicolas!

@clemherreman
Copy link
Contributor

Yup, much better explained than I tried to. Thank you :)

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

Successfully merging this pull request may close these issues.

7 participants