From 47b11068683f9750729d87f6b7c24524ae46607a Mon Sep 17 00:00:00 2001 From: Yonel Ceruto Date: Thu, 7 Sep 2017 11:35:49 -0400 Subject: [PATCH] Do not display short exception trace for built-in console exceptions --- src/Symfony/Component/Console/Application.php | 4 +++- .../Console/Tests/Fixtures/application_renderexception1.txt | 1 - .../Console/Tests/Fixtures/application_renderexception2.txt | 1 - .../Console/Tests/Fixtures/application_renderexception4.txt | 1 - 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index 41c2a238e08a1..9cebe5768b26e 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -761,7 +761,9 @@ protected function doRenderException(\Exception $e, OutputInterface $output) } $messages = array(); - $messages[] = sprintf('%s', OutputFormatter::escape(sprintf('In %s line %s:', basename($e->getFile()) ?: 'n/a', $e->getLine() ?: 'n/a'))); + if (!$e instanceof ExceptionInterface || OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { + $messages[] = sprintf('%s', OutputFormatter::escape(sprintf('In %s line %s:', basename($e->getFile()) ?: 'n/a', $e->getLine() ?: 'n/a'))); + } $messages[] = $emptyLine = sprintf('%s', str_repeat(' ', $len)); if ('' === $message || OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { $messages[] = sprintf('%s%s', $title, str_repeat(' ', max(0, $len - Helper::strlen($title)))); diff --git a/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception1.txt b/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception1.txt index 700ffada3d2fa..1df5bd6494bbf 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception1.txt +++ b/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception1.txt @@ -1,5 +1,4 @@ -In Application.php line 615: 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 457e6df46c0a9..932063d730d67 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception2.txt +++ b/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception2.txt @@ -1,5 +1,4 @@ -In ArrayInput.php line 178: The "--foo" option does not exist. diff --git a/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception4.txt b/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception4.txt index 040564447f57b..548a13e56f22e 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception4.txt +++ b/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception4.txt @@ -1,5 +1,4 @@ -In Application.php line 615: Command "foo" is not define d.