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
[HttpClient] - Cannot catch TransportException error #34281
Comments
As stated in the doc, responses are lazy: https://symfony.com/doc/current/components/http_client.html The exception happens after the call to request(), at destruction time - ie outside of the try/catch. |
Ahhh, feels weird, but got it now. Thanks! |
Well, the goal of lazyness is that you can start multiple requests, and waits only after that. This way, the network can run them in parallel. |
Do you think that is there a room for documentation improvement? How do you recommend to catch-up the exceptions within lazy approach? So far, I'm using:
|
Not this way @er1z - that disables a safety measure that requires ppl to write correct error handling code. |
@nicolas-grekas so what is a better way? |
It depends on the use case: if one doesn't care about the response, there is no need to create a variable for it. |
I had the same error in Symfony5, and I solved adding |
Symfony version(s) affected:
symfony/http-client v4.3.4
Description
I am having trouble catching
Symfony\Component\HttpClient\Exception\TransportException
when doing a GET request on servers without SSL installed.How to reproduce
Trying to catch,
\Symfony\Component\HttpClient\Exception\TransportException
nor\Exception
nor\Throwable
doesn't seem to help.Still throws
Fatal error
: https://pastebin.com/raw/edfnSeu5PS
In case it might help, I have the following packages too:
composer show
https://pastebin.com/raw/mXJSxqQjcomposer.json
https://pastebin.com/raw/05PbqDZSHope somebody can help.
The text was updated successfully, but these errors were encountered: