Skip to content

Commit

Permalink
minor #50123 [HttpClient] Adjust JsonMockResponse exception (alamir…
Browse files Browse the repository at this point in the history
…ault)

This PR was merged into the 6.3 branch.

Discussion
----------

[HttpClient] Adjust `JsonMockResponse` exception

| Q             | A
| ------------- | ---
| Branch?       | 6.3
| Bug fix?      | no
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exists, explain below instead -->
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->

Minor adjustement of #50044

Set previous exception when throwing InvalidArgumentException as suggested by `@stof` in https://github.com/symfony/symfony/pull/50044/files#r1172519397

Commits
-------

48a953f [HttpClient] Adjust JsonMockResponse exception
  • Loading branch information
nicolas-grekas committed Apr 23, 2023
2 parents 6c28196 + 48a953f commit f6e6afa
Showing 1 changed file with 1 addition and 1 deletion.
Expand Up @@ -20,7 +20,7 @@ public function __construct(mixed $body = [], array $info = [])
try {
$json = json_encode($body, \JSON_THROW_ON_ERROR);
} catch (\JsonException $e) {
throw new InvalidArgumentException('JSON encoding failed: '.$e->getMessage(), $e->getCode());
throw new InvalidArgumentException('JSON encoding failed: '.$e->getMessage(), $e->getCode(), $e);
}

$info['response_headers']['content-type'] ??= 'application/json';
Expand Down

0 comments on commit f6e6afa

Please sign in to comment.