-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[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
Conversation
738cfec
to
ea38d7f
Compare
ea38d7f
to
61cddf5
Compare
Perfectly describes what really happens, definitely missing part of docs - 👍 |
There was a problem hiding this 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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
Thanks Nicolas! |
Yup, much better explained than I tried to. Thank you :) |
Replaces #13078 and #13134