4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\HttpKernel\Event;
14 use Symfony\Component\HttpKernel\HttpKernelInterface;
15 use Symfony\Component\HttpFoundation\Request;
18 * Allows to create a response for a thrown exception.
20 * Call setResponse() to set the response that will be returned for the
21 * current request. The propagation of this event is stopped as soon as a
24 * You can also call setException() to replace the thrown exception. This
25 * exception will be thrown if no response is set during processing of this
28 * @author Bernhard Schussek <bschussek@gmail.com>
30 class GetResponseForExceptionEvent extends GetResponseEvent
33 * The exception object.
39 public function __construct(HttpKernelInterface $kernel, Request $request, $requestType, \Exception $e)
41 parent::__construct($kernel, $request, $requestType);
43 $this->setException($e);
47 * Returns the thrown exception.
49 * @return \Exception The thrown exception
51 public function getException()
53 return $this->exception;
57 * Replaces the thrown exception.
59 * This exception will be thrown if no response is set in the event.
61 * @param \Exception $exception The thrown exception
63 public function setException(\Exception $exception)
65 $this->exception = $exception;