aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJeremy Benoist <j0k3r@users.noreply.github.com>2016-10-10 07:09:45 +0200
committerGitHub <noreply@github.com>2016-10-10 07:09:45 +0200
commite93c9dc4ab568e9f894f966967983826134b0f76 (patch)
tree8fe481212f08080e02fc3f2a40b2a04ec83f3786
parent47508f004fe9a17a8012187f37032f4155d507f4 (diff)
parent39a19bdf478583f9b63a2b1a98746a713e217c86 (diff)
downloadwallabag-e93c9dc4ab568e9f894f966967983826134b0f76.tar.gz
wallabag-e93c9dc4ab568e9f894f966967983826134b0f76.tar.zst
wallabag-e93c9dc4ab568e9f894f966967983826134b0f76.zip
Merge pull request #2413 from wallabag/sub-command-verbose
When a sub command fail, display error message
-rw-r--r--src/Wallabag/CoreBundle/Command/InstallCommand.php17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php
index cc7c2c94..8e438229 100644
--- a/src/Wallabag/CoreBundle/Command/InstallCommand.php
+++ b/src/Wallabag/CoreBundle/Command/InstallCommand.php
@@ -9,7 +9,7 @@ use Symfony\Component\Console\Helper\Table;
9use Symfony\Component\Console\Input\ArrayInput; 9use Symfony\Component\Console\Input\ArrayInput;
10use Symfony\Component\Console\Input\InputInterface; 10use Symfony\Component\Console\Input\InputInterface;
11use Symfony\Component\Console\Input\InputOption; 11use Symfony\Component\Console\Input\InputOption;
12use Symfony\Component\Console\Output\NullOutput; 12use Symfony\Component\Console\Output\BufferedOutput;
13use Symfony\Component\Console\Output\OutputInterface; 13use Symfony\Component\Console\Output\OutputInterface;
14use Symfony\Component\Console\Question\ConfirmationQuestion; 14use Symfony\Component\Console\Question\ConfirmationQuestion;
15use Symfony\Component\Console\Question\Question; 15use Symfony\Component\Console\Question\Question;
@@ -97,7 +97,8 @@ class InstallCommand extends ContainerAwareCommand
97 try { 97 try {
98 $this->getContainer()->get('doctrine')->getManager()->getConnection()->connect(); 98 $this->getContainer()->get('doctrine')->getManager()->getConnection()->connect();
99 } catch (\Exception $e) { 99 } catch (\Exception $e) {
100 if (false === strpos($e->getMessage(), 'Unknown database')) { 100 if (false === strpos($e->getMessage(), 'Unknown database')
101 && false === strpos($e->getMessage(), 'database "'.$this->getContainer()->getParameter('database_name').'" does not exist')) {
101 $fulfilled = false; 102 $fulfilled = false;
102 $status = '<error>ERROR!</error>'; 103 $status = '<error>ERROR!</error>';
103 $help = 'Can\'t connect to the database: '.$e->getMessage(); 104 $help = 'Can\'t connect to the database: '.$e->getMessage();
@@ -420,16 +421,18 @@ class InstallCommand extends ContainerAwareCommand
420 } 421 }
421 422
422 $this->getApplication()->setAutoExit(false); 423 $this->getApplication()->setAutoExit(false);
423 $exitCode = $this->getApplication()->run(new ArrayInput($parameters), new NullOutput()); 424
425 $output = new BufferedOutput();
426 $exitCode = $this->getApplication()->run(new ArrayInput($parameters), $output);
424 427
425 if (0 !== $exitCode) { 428 if (0 !== $exitCode) {
426 $this->getApplication()->setAutoExit(true); 429 $this->getApplication()->setAutoExit(true);
427 430
428 $errorMessage = sprintf('The command "%s" terminated with an error code: %u.', $command, $exitCode); 431 $this->defaultOutput->writeln('');
429 $this->defaultOutput->writeln("<error>$errorMessage</error>"); 432 $this->defaultOutput->writeln('<error>The command "'.$command.'" generates some errors: </error>');
430 $exception = new \Exception($errorMessage, $exitCode); 433 $this->defaultOutput->writeln($output->fetch());
431 434
432 throw $exception; 435 die();
433 } 436 }
434 437
435 // PDO does not always close the connection after Doctrine commands. 438 // PDO does not always close the connection after Doctrine commands.