Skip to content

[Console] Avoid extra blank lines when rendering exceptions #17040

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 18, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/Symfony/Component/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,8 @@ public function asXml($namespace = null, $asDom = false)
*/
public function renderException($e, $output)
{
$output->writeln('');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beware when merging in upper branches. Since 2.8, this should be:

- $output->writeln('');
+ $output->writeln('', OutputInterface::VERBOSITY_QUIET);


do {
$title = sprintf(' [%s] ', get_class($e));

Expand All @@ -695,15 +697,14 @@ public function renderException($e, $output)
}
}

$messages = array('', '');
$messages = array();
$messages[] = $emptyLine = $formatter->format(sprintf('<error>%s</error>', str_repeat(' ', $len)));
$messages[] = $formatter->format(sprintf('<error>%s%s</error>', $title, str_repeat(' ', max(0, $len - $this->stringWidth($title)))));
foreach ($lines as $line) {
$messages[] = $formatter->format(sprintf('<error> %s %s</error>', $line[0], str_repeat(' ', $len - $line[1])));
}
$messages[] = $emptyLine;
$messages[] = '';
$messages[] = '';

$output->writeln($messages, OutputInterface::OUTPUT_RAW);

Expand All @@ -730,14 +731,12 @@ public function renderException($e, $output)
}

$output->writeln('');
$output->writeln('');
}
} while ($e = $e->getPrevious());

if (null !== $this->runningCommand) {
$output->writeln(sprintf('<info>%s</info>', sprintf($this->runningCommand->getSynopsis(), $this->getName())));
$output->writeln('');
$output->writeln('');
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@



[InvalidArgumentException]
Command "foo" is not defined.



Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@



[InvalidArgumentException]
The "--foo" option does not exist.



list [--xml] [--raw] [--format="..."] [namespace]


Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@



[Exception]
Third exception comment






[Exception]
Second exception comment






[Exception]
First exception <p>this is html</p>



foo3:bar


Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@


 
 [Exception] 
 Third exception comment 
 




 
 [Exception] 
 Second exception comment 
 




 
 [Exception] 
 First exception <p>this is html</p> 
 


foo3:bar


Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@



[InvalidArgumentException]
Command "foo" is not define
d.



Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@



[Exception]
エラーメッセージ



foo


Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@


 
 [Exception] 
 エラーメッセージ 
 


foo


Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@



[Exception]
コマンドの実行中にエラーが
発生しました。



foo