Skip to content

Commit ec8edee

Browse files
committed
feature symfony#22890 [HttpKernel] Add ability to configure catching exceptions for Client (kbond)
This PR was merged into the 3.4 branch. Discussion ---------- [HttpKernel] Add ability to configure catching exceptions for Client | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | todo Debugging exceptions in functional tests is difficult as you need to look at the logs to see which exception was thrown. Disabling catching of exceptions in the client would allow the exception to bubble up to phpunit and make it easier to see what exception was thrown. Commits ------- 4812e60 add ability to configure catching exceptions
2 parents 07f7973 + 4812e60 commit ec8edee

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/Symfony/Component/HttpKernel/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ CHANGELOG
1111
* added `AddCacheClearerPass`
1212
* added `AddCacheWarmerPass`
1313
* deprecated `EnvParametersResource`
14+
* added `Symfony\Component\HttpKernel\Client::catchExceptions()`
1415

1516
3.3.0
1617
-----

src/Symfony/Component/HttpKernel/Client.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
class Client extends BaseClient
3232
{
3333
protected $kernel;
34+
private $catchExceptions = true;
3435

3536
/**
3637
* Constructor.
@@ -49,6 +50,16 @@ public function __construct(HttpKernelInterface $kernel, array $server = array()
4950
parent::__construct($server, $history, $cookieJar);
5051
}
5152

53+
/**
54+
* Sets whether to catch exceptions when the kernel is handling a request.
55+
*
56+
* @param bool $catchExceptions Whether to catch exceptions
57+
*/
58+
public function catchExceptions($catchExceptions)
59+
{
60+
$this->catchExceptions = $catchExceptions;
61+
}
62+
5263
/**
5364
* Makes a request.
5465
*
@@ -58,7 +69,7 @@ public function __construct(HttpKernelInterface $kernel, array $server = array()
5869
*/
5970
protected function doRequest($request)
6071
{
61-
$response = $this->kernel->handle($request);
72+
$response = $this->kernel->handle($request, HttpKernelInterface::MASTER_REQUEST, $this->catchExceptions);
6273

6374
if ($this->kernel instanceof TerminableInterface) {
6475
$this->kernel->terminate($request, $response);

0 commit comments

Comments
 (0)