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\Console\Event;
14 use Symfony\Component\Console\Command\Command;
15 use Symfony\Component\Console\Input\InputInterface;
16 use Symfony\Component\Console\Output\OutputInterface;
19 * Allows to handle exception thrown in a command.
21 * @author Fabien Potencier <fabien@symfony.com>
23 class ConsoleExceptionEvent extends ConsoleEvent
28 public function __construct(Command $command, InputInterface $input, OutputInterface $output, \Exception $exception, $exitCode)
30 parent::__construct($command, $input, $output);
32 $this->setException($exception);
33 $this->exitCode = (int) $exitCode;
37 * Returns the thrown exception.
39 * @return \Exception The thrown exception
41 public function getException()
43 return $this->exception;
47 * Replaces the thrown exception.
49 * This exception will be thrown if no response is set in the event.
51 * @param \Exception $exception The thrown exception
53 public function setException(\Exception $exception)
55 $this->exception = $exception;
61 * @return int The command exit code
63 public function getExitCode()
65 return $this->exitCode;