X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FCommand%2FInstallCommand.php;h=591107821c854345f8e133fbb6d219f19b27fffa;hb=e4cf672ccf61689ba28c2e89fc55f83167800b18;hp=42982e4a42240af3f9ed3647cc0866922131197c;hpb=e57df5611fe82ce61a71d51c762ee9296f18c3ac;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php index 42982e4a..59110782 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; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Output\NullOutput; +use Symfony\Component\Console\Output\BufferedOutput; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\ConfirmationQuestion; use Symfony\Component\Console\Question\Question; @@ -97,7 +97,8 @@ class InstallCommand extends ContainerAwareCommand try { $this->getContainer()->get('doctrine')->getManager()->getConnection()->connect(); } catch (\Exception $e) { - if (false === strpos($e->getMessage(), 'Unknown database')) { + if (false === strpos($e->getMessage(), 'Unknown database') + && false === strpos($e->getMessage(), 'database "'.$this->getContainer()->getParameter('database_name').'" does not exist')) { $fulfilled = false; $status = 'ERROR!'; $help = 'Can\'t connect to the database: '.$e->getMessage(); @@ -420,16 +421,18 @@ class InstallCommand extends ContainerAwareCommand } $this->getApplication()->setAutoExit(false); - $exitCode = $this->getApplication()->run(new ArrayInput($parameters), new NullOutput()); + + $output = new BufferedOutput(); + $exitCode = $this->getApplication()->run(new ArrayInput($parameters), $output); if (0 !== $exitCode) { $this->getApplication()->setAutoExit(true); - $errorMessage = sprintf('The command "%s" terminated with an error code: %u.', $command, $exitCode); - $this->defaultOutput->writeln("$errorMessage"); - $exception = new \Exception($errorMessage, $exitCode); + $this->defaultOutput->writeln(''); + $this->defaultOutput->writeln('The command "'.$command.'" generates some errors: '); + $this->defaultOutput->writeln($output->fetch()); - throw $exception; + die(); } // PDO does not always close the connection after Doctrine commands.