Chris@0: Chris@0: * Chris@0: * For the full copyright and license information, please view the LICENSE Chris@0: * file that was distributed with this source code. Chris@0: */ Chris@0: Chris@0: namespace Symfony\Component\Console\Event; Chris@0: Chris@14: @trigger_error(sprintf('The "%s" class is deprecated since Symfony 3.3 and will be removed in 4.0. Use the ConsoleErrorEvent instead.', ConsoleExceptionEvent::class), E_USER_DEPRECATED); Chris@14: Chris@0: use Symfony\Component\Console\Command\Command; Chris@0: use Symfony\Component\Console\Input\InputInterface; Chris@0: use Symfony\Component\Console\Output\OutputInterface; Chris@0: Chris@0: /** Chris@0: * Allows to handle exception thrown in a command. Chris@0: * Chris@0: * @author Fabien Potencier Chris@14: * Chris@14: * @deprecated since version 3.3, to be removed in 4.0. Use ConsoleErrorEvent instead. Chris@0: */ Chris@0: class ConsoleExceptionEvent extends ConsoleEvent Chris@0: { Chris@0: private $exception; Chris@0: private $exitCode; Chris@0: Chris@0: public function __construct(Command $command, InputInterface $input, OutputInterface $output, \Exception $exception, $exitCode) Chris@0: { Chris@0: parent::__construct($command, $input, $output); Chris@0: Chris@0: $this->setException($exception); Chris@0: $this->exitCode = (int) $exitCode; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Returns the thrown exception. Chris@0: * Chris@0: * @return \Exception The thrown exception Chris@0: */ Chris@0: public function getException() Chris@0: { Chris@0: return $this->exception; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Replaces the thrown exception. Chris@0: * Chris@0: * This exception will be thrown if no response is set in the event. Chris@0: * Chris@0: * @param \Exception $exception The thrown exception Chris@0: */ Chris@0: public function setException(\Exception $exception) Chris@0: { Chris@0: $this->exception = $exception; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Gets the exit code. Chris@0: * Chris@0: * @return int The command exit code Chris@0: */ Chris@0: public function getExitCode() Chris@0: { Chris@0: return $this->exitCode; Chris@0: } Chris@0: }