Closed
Description
Q | A |
---|---|
Bug report? | yes |
Feature request? | no |
BC Break report? | no |
RFC? | no |
Symfony version | 3.2.7 |
When a Console Command throw an exception, sometimes exit code will be 1
, sometimes 0
I think this is not only for 3.2
, i have this problem since long time.
<?php
declare(strict_types=1);
namespace Foo;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
class GenerateInvoiceCommand extends ContainerAwareCommand
{
protected function configure()
{
$this->setName('foo:bar');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
// $toto is undefined, it will throw a ContextErrorException
// exit code 1
echo $toto;
// exit code 1
throw new \Exception('foo');
// unkonwMethod() does not exist, it will throw an UndefinedMethodException
// exit code 0
$output->unkonwnMethod();
}
}
php bin/console foo:bar
echo "$?"