diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index 99548faf858b8..d4ec1be090927 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -298,6 +298,8 @@ public function doRun(InputInterface $input, OutputInterface $output) return isset($event) ? $event->getExitCode() : 1; } + + throw $e; } catch (NamespaceNotFoundException) { throw $e; } diff --git a/src/Symfony/Component/Console/Tests/ApplicationTest.php b/src/Symfony/Component/Console/Tests/ApplicationTest.php index c178151688928..c82c3eb188418 100644 --- a/src/Symfony/Component/Console/Tests/ApplicationTest.php +++ b/src/Symfony/Component/Console/Tests/ApplicationTest.php @@ -18,6 +18,7 @@ use Symfony\Component\Console\Command\HelpCommand; use Symfony\Component\Console\Command\LazyCommand; use Symfony\Component\Console\Command\SignalableCommandInterface; +use Symfony\Component\Console\CommandLoader\CommandLoaderInterface; use Symfony\Component\Console\CommandLoader\FactoryCommandLoader; use Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass; use Symfony\Component\Console\Event\ConsoleCommandEvent; @@ -1466,6 +1467,25 @@ public function testRunWithError() } } + public function testRunWithFindError() + { + $this->expectException(\Error::class); + $this->expectExceptionMessage('Find exception'); + + $application = new Application(); + $application->setAutoExit(false); + $application->setCatchExceptions(false); + + // Throws an exception when find fails + $commandLoader = $this->createMock(CommandLoaderInterface::class); + $commandLoader->method('getNames')->willThrowException(new \Error('Find exception')); + $application->setCommandLoader($commandLoader); + + // The exception should not be ignored + $tester = new ApplicationTester($application); + $tester->run(['command' => 'foo']); + } + public function testRunAllowsErrorListenersToSilenceTheException() { $dispatcher = $this->getDispatcher();