You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The toString method of the Uri class doesn't throw exceptions. It just calls this method: https://github.com/guzzle/psr7/blob/master/src/Uri.php#L480. I don't see how it would have directly called anything from the Guzzle client because this project doesn't know about Guzzle. Can you show what your test does?
The issue ended up not being with Guzzle at all, but was due to how our test suite was set up.
In our subclass of PHPUnit_Framework_TestCase, we were overriding tearDown() and from there calling GuzzleHttp\Promise\unwrap() with an array of GuzzleHttp\Promise\PromiseInterface instances obtained from calling GuzzleHttp\Client->*Async() methods.
When Guzzle encounters an error condition (e.g. a response with a 401 status code), it throws an instance of GuzzleHttp\Exception\ClientException. We had a try / catch block in tearDown() to handle this condition by obtaining relevant debugging information and throwing a new RuntimeException instance.
The actual problem was that this catch block was causing a PHP notice to be emitted. If we excluded E_NOTICE from the error_reporting setting, the tests ran without encountering the condition originally reported in this issue, which appeared to happen partly due to a behavior of PHPUnit.
By default, PHPUnit converts PHP errors, warnings, and notices that are triggered during the execution of a test to an exception.
By calling restore_error_handler() in setUp() in our test case class, we were able to deactivate PHPUnit's custom error handler, revealing the PHP notice being emitted, which as it turns out was completely unrelated to Uri::__toString().
I'm not altogether certain why the error originally reported here was the result of all of this. All attempts to debug an issue in Uri::__toString() -- adding a try / catch block there, outputting backtraces, etc. failed because the issue simply wasn't with that area of code.
Hello, I'm running into this fatal error with one of my tests:
It appears to stem from a call to GuzzleHttp\Client::getAsync(), though wrapping that call in a try/catch doesn't seem to catch an exception.
Thanks
The text was updated successfully, but these errors were encountered: