add ability to configure catching exceptions

This commit is contained in:
Kevin Bond 2017-05-24 11:00:21 -04:00
parent bc8430418b
commit 4812e6054c
No known key found for this signature in database
GPG Key ID: C5242A715A168E24
2 changed files with 13 additions and 1 deletions

View File

@ -11,6 +11,7 @@ CHANGELOG
* added `AddCacheClearerPass`
* added `AddCacheWarmerPass`
* deprecated `EnvParametersResource`
* added `Symfony\Component\HttpKernel\Client::catchExceptions()`
3.3.0
-----

View File

@ -31,6 +31,7 @@ use Symfony\Component\HttpFoundation\Response;
class Client extends BaseClient
{
protected $kernel;
private $catchExceptions = true;
/**
* Constructor.
@ -49,6 +50,16 @@ class Client extends BaseClient
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 @@ class Client extends BaseClient
*/
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);