From 4812e6054c14994eab0513d6dc4ba108c2d0f156 Mon Sep 17 00:00:00 2001 From: Kevin Bond Date: Wed, 24 May 2017 11:00:21 -0400 Subject: [PATCH] add ability to configure catching exceptions --- src/Symfony/Component/HttpKernel/CHANGELOG.md | 1 + src/Symfony/Component/HttpKernel/Client.php | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpKernel/CHANGELOG.md b/src/Symfony/Component/HttpKernel/CHANGELOG.md index 8732b17dd83f..66e3b38e25ce 100644 --- a/src/Symfony/Component/HttpKernel/CHANGELOG.md +++ b/src/Symfony/Component/HttpKernel/CHANGELOG.md @@ -11,6 +11,7 @@ CHANGELOG * added `AddCacheClearerPass` * added `AddCacheWarmerPass` * deprecated `EnvParametersResource` + * added `Symfony\Component\HttpKernel\Client::catchExceptions()` 3.3.0 ----- diff --git a/src/Symfony/Component/HttpKernel/Client.php b/src/Symfony/Component/HttpKernel/Client.php index 94f70cd6f7a0..4a86564c9f9f 100644 --- a/src/Symfony/Component/HttpKernel/Client.php +++ b/src/Symfony/Component/HttpKernel/Client.php @@ -31,6 +31,7 @@ class Client extends BaseClient { protected $kernel; + private $catchExceptions = true; /** * Constructor. @@ -49,6 +50,16 @@ public function __construct(HttpKernelInterface $kernel, array $server = array() parent::__construct($server, $history, $cookieJar); } + /** + * Sets whether to catch exceptions when the kernel is handling a request. + * + * @param bool $catchExceptions Whether to catch exceptions + */ + public function catchExceptions($catchExceptions) + { + $this->catchExceptions = $catchExceptions; + } + /** * Makes a request. * @@ -58,7 +69,7 @@ public function __construct(HttpKernelInterface $kernel, array $server = array() */ protected function doRequest($request) { - $response = $this->kernel->handle($request); + $response = $this->kernel->handle($request, HttpKernelInterface::MASTER_REQUEST, $this->catchExceptions); if ($this->kernel instanceof TerminableInterface) { $this->kernel->terminate($request, $response);