Skip to content

[HttpClient][MockHttpClient][DX] Throw when the response factory callable does not return a valid response#37966

Merged
fabpot merged 1 commit intosymfony:4.4from
fancyweb:http-client-mock-client-response-factory-throw
Aug 30, 2020
Merged

[HttpClient][MockHttpClient][DX] Throw when the response factory callable does not return a valid response#37966
fabpot merged 1 commit intosymfony:4.4from
fancyweb:http-client-mock-client-response-factory-throw

Conversation

@fancyweb
Copy link
Copy Markdown
Contributor

Q A
Branch? 4.4
Bug fix? no
New feature? no
Deprecations? no
Tickets -
License MIT
Doc PR -

The current message is TypeError: Argument 4 passed to Symfony\Component\HttpClient\Response\MockResponse::fromRequest() must implement interface Symfony\Contracts\HttpClient\ResponseInterface, instance of Generator given.

I lost some time with this because I was passing a callable that returns a \Generator instead of passing the resulting \Generator directly. We could support that case but I guess with the added exception message, it is clear we don't support it at all.

@carsonbot carsonbot added Status: Needs Review HttpClient DX DX = Developer eXperience (anything that improves the experience of using Symfony) labels Aug 27, 2020
@nicolas-grekas nicolas-grekas added this to the 4.4 milestone Aug 27, 2020
@fancyweb fancyweb force-pushed the http-client-mock-client-response-factory-throw branch from fef0c62 to c11482f Compare August 28, 2020 08:03
@fancyweb fancyweb force-pushed the http-client-mock-client-response-factory-throw branch from c11482f to 564dce3 Compare August 28, 2020 12:31
@fabpot
Copy link
Copy Markdown
Member

fabpot commented Aug 30, 2020

Thank you @fancyweb.

@fabpot fabpot merged commit 4d6ea77 into symfony:4.4 Aug 30, 2020
This was referenced Aug 31, 2020
@fancyweb fancyweb deleted the http-client-mock-client-response-factory-throw branch August 31, 2020 07:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DX DX = Developer eXperience (anything that improves the experience of using Symfony) HttpClient Status: Reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants