From 2e158df2c7c100576dafa89dfe72b84239e79695 Mon Sep 17 00:00:00 2001 From: Maxime Steinhausser Date: Thu, 17 Dec 2015 00:26:14 +0100 Subject: [PATCH] [Console] Avoid extra blank lines when rendering exceptions --- src/Symfony/Component/Console/Application.php | 7 +++---- .../Tests/Fixtures/application_renderexception1.txt | 2 -- .../Tests/Fixtures/application_renderexception2.txt | 3 --- .../Tests/Fixtures/application_renderexception3.txt | 9 --------- .../Fixtures/application_renderexception3decorated.txt | 9 --------- .../Tests/Fixtures/application_renderexception4.txt | 2 -- .../application_renderexception_doublewidth1.txt | 3 --- ...application_renderexception_doublewidth1decorated.txt | 3 --- .../application_renderexception_doublewidth2.txt | 3 --- 9 files changed, 3 insertions(+), 38 deletions(-) diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index eb665e5bdb..6140d3af6e 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -673,6 +673,8 @@ class Application */ public function renderException($e, $output) { + $output->writeln(''); + do { $title = sprintf(' [%s] ', get_class($e)); @@ -695,7 +697,7 @@ class Application } } - $messages = array('', ''); + $messages = array(); $messages[] = $emptyLine = $formatter->format(sprintf('%s', str_repeat(' ', $len))); $messages[] = $formatter->format(sprintf('%s%s', $title, str_repeat(' ', max(0, $len - $this->stringWidth($title))))); foreach ($lines as $line) { @@ -703,7 +705,6 @@ class Application } $messages[] = $emptyLine; $messages[] = ''; - $messages[] = ''; $output->writeln($messages, OutputInterface::OUTPUT_RAW); @@ -730,14 +731,12 @@ class Application } $output->writeln(''); - $output->writeln(''); } } while ($e = $e->getPrevious()); if (null !== $this->runningCommand) { $output->writeln(sprintf('%s', sprintf($this->runningCommand->getSynopsis(), $this->getName()))); $output->writeln(''); - $output->writeln(''); } } diff --git a/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception1.txt b/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception1.txt index 4629345c1e..c56f4b6033 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception1.txt +++ b/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception1.txt @@ -1,8 +1,6 @@ - [InvalidArgumentException] Command "foo" is not defined. - diff --git a/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception2.txt b/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception2.txt index c758129bee..cf4880d206 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception2.txt +++ b/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception2.txt @@ -1,11 +1,8 @@ - [InvalidArgumentException] The "--foo" option does not exist. - list [--xml] [--raw] [--format="..."] [namespace] - diff --git a/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception3.txt b/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception3.txt index 72a72867f3..8276137bd8 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception3.txt +++ b/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception3.txt @@ -1,27 +1,18 @@ - [Exception] Third exception comment - - - [Exception] Second exception comment - - - [Exception] First exception

this is html

- foo3:bar - diff --git a/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception3decorated.txt b/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception3decorated.txt index 4bdcd772ca..718a181986 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception3decorated.txt +++ b/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception3decorated.txt @@ -1,27 +1,18 @@ -    [Exception]   Third exception comment    - - -    [Exception]   Second exception comment    - - -    [Exception]   First exception 

this is html

    - foo3:bar - diff --git a/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception4.txt b/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception4.txt index 19f893b0c8..9d881e7d0f 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception4.txt +++ b/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception4.txt @@ -1,9 +1,7 @@ - [InvalidArgumentException] Command "foo" is not define d. - diff --git a/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception_doublewidth1.txt b/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception_doublewidth1.txt index 6a98660364..1ba5f8fdd9 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception_doublewidth1.txt +++ b/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception_doublewidth1.txt @@ -1,11 +1,8 @@ - [Exception] エラーメッセージ - foo - diff --git a/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception_doublewidth1decorated.txt b/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception_doublewidth1decorated.txt index c68a60f564..f65b3f89ba 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception_doublewidth1decorated.txt +++ b/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception_doublewidth1decorated.txt @@ -1,11 +1,8 @@ -    [Exception]   エラーメッセージ    - foo - diff --git a/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception_doublewidth2.txt b/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception_doublewidth2.txt index 545cd7b0b4..e41fcfcf67 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception_doublewidth2.txt +++ b/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception_doublewidth2.txt @@ -1,12 +1,9 @@ - [Exception] コマンドの実行中にエラーが 発生しました。 - foo -