symfony: [HttpClient] Can we not trigger_error and throw exception or log warning instead?

Description StreamWrapper triggers error (lvl warning).

https://github.com/symfony/symfony/blob/b5d4b33d5e65d956194c170fda5f8f40bc6a921a/src/Symfony/Component/HttpClient/Response/StreamWrapper.php#L185

This causes an issue because it always falls into an error handler that is currently set (set_error_handler()).

So even though I catch the error using catch(ErrorException){ }, the error handler is triggered anyways.

Example Sentry php sdk sets its own error handler. trigger_error() triggers it without me having any control over it. So I have to unset the error handler before making a request and then set it back again.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 19 (19 by maintainers)

Most upvoted comments

libs that call stream_get_contents() should wrap the call in something like

almost yes (I would not call error_reporting() because here we always want to report the error, and I would pass any deprecations to the previous error handler, if any.)

Or they can skip that and add @ in front of the call they do (but then I’d hope they’d use error_get_last() to provide useful error messages.

Hmm, interesting. With httpbin, I’m encountering the same behaviour as you. Might be related to request body or/and the device at the end which you can imagine as a kind of Tamagotchi. Will investigate flow path/get something reproducible and get back. Thanks for your time!

Where is $message coming from?