Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2e158df

Browse files
committed
[Console] Avoid extra blank lines when rendering exceptions
1 parent b23c9a3 commit 2e158df

9 files changed

+3
-38
lines changed

src/Symfony/Component/Console/Application.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,8 @@ public function asXml($namespace = null, $asDom = false)
673673
*/
674674
public function renderException($e, $output)
675675
{
676+
$output->writeln('');
677+
676678
do {
677679
$title = sprintf(' [%s] ', get_class($e));
678680

@@ -695,15 +697,14 @@ public function renderException($e, $output)
695697
}
696698
}
697699

698-
$messages = array('', '');
700+
$messages = array();
699701
$messages[] = $emptyLine = $formatter->format(sprintf('<error>%s</error>', str_repeat(' ', $len)));
700702
$messages[] = $formatter->format(sprintf('<error>%s%s</error>', $title, str_repeat(' ', max(0, $len - $this->stringWidth($title)))));
701703
foreach ($lines as $line) {
702704
$messages[] = $formatter->format(sprintf('<error> %s %s</error>', $line[0], str_repeat(' ', $len - $line[1])));
703705
}
704706
$messages[] = $emptyLine;
705707
$messages[] = '';
706-
$messages[] = '';
707708

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

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

732733
$output->writeln('');
733-
$output->writeln('');
734734
}
735735
} while ($e = $e->getPrevious());
736736

737737
if (null !== $this->runningCommand) {
738738
$output->writeln(sprintf('<info>%s</info>', sprintf($this->runningCommand->getSynopsis(), $this->getName())));
739739
$output->writeln('');
740-
$output->writeln('');
741740
}
742741
}
743742

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11

2-
32

43
[InvalidArgumentException]
54
Command "foo" is not defined.
65

76

8-
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11

2-
32

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

76

8-
97
list [--xml] [--raw] [--format="..."] [namespace]
108

11-
Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,18 @@
11

2-
32

43
[Exception]
54
Third exception comment
65

76

8-
9-
10-
117

128
[Exception]
139
Second exception comment
1410

1511

16-
17-
18-
1912

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

2316

24-
2517
foo3:bar
2618

27-
Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,18 @@
11

2-
32
 
43
 [Exception] 
54
 Third exception comment 
65
 
76

8-
9-
10-
117
 
128
 [Exception] 
139
 Second exception comment 
1410
 
1511

16-
17-
18-
1912
 
2013
 [Exception] 
2114
 First exception <p>this is html</p> 
2215
 
2316

24-
2517
foo3:bar
2618

27-
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11

2-
32

43
[InvalidArgumentException]
54
Command "foo" is not define
65
d.
76

87

9-
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11

2-
32

43
[Exception]
54
エラーメッセージ
65

76

8-
97
foo
108

11-
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11

2-
32
 
43
 [Exception] 
54
 エラーメッセージ 
65
 
76

8-
97
foo
108

11-
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11

2-
32

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

87

9-
108
foo
119

12-

0 commit comments

Comments
 (0)