Giter Club home page Giter Club logo

Comments (2)

mtdowling avatar mtdowling commented on May 1, 2024

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?

from psr7.

elazar avatar elazar commented on May 1, 2024

For posterity:

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.

https://phpunit.de/manual/current/en/writing-tests-for-phpunit.html#writing-tests-for-phpunit.errors

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.

from psr7.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.