Skip to content

Commit 4dff24e

Browse files
Merge branch '4.1' into 4.2
* 4.1: Update PR template bumped Symfony version to 4.1.9 updated VERSION for 4.1.8 updated CHANGELOG for 4.1.8 bumped Symfony version to 3.4.20 updated VERSION for 3.4.19 updated CHANGELOG for 3.4.19 [Console] Move back root exception to stack trace in verbose mode
2 parents 1099760 + c74f4d1 commit 4dff24e

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

Application.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,13 @@ protected function doRenderException(\Exception $e, OutputInterface $output)
801801
// exception related properties
802802
$trace = $e->getTrace();
803803

804+
array_unshift($trace, array(
805+
'function' => '',
806+
'file' => $e->getFile() ?: 'n/a',
807+
'line' => $e->getLine() ?: 'n/a',
808+
'args' => array(),
809+
));
810+
804811
for ($i = 0, $count = \count($trace); $i < $count; ++$i) {
805812
$class = isset($trace[$i]['class']) ? $trace[$i]['class'] : '';
806813
$type = isset($trace[$i]['type']) ? $trace[$i]['type'] : '';

Tests/ApplicationTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,31 @@ public function testRenderAnonymousException()
849849
$this->assertContains('Dummy type "@anonymous" is invalid.', $tester->getDisplay(true));
850850
}
851851

852+
public function testRenderExceptionStackTraceContainsRootException()
853+
{
854+
$application = new Application();
855+
$application->setAutoExit(false);
856+
$application->register('foo')->setCode(function () {
857+
throw new class('') extends \InvalidArgumentException {
858+
};
859+
});
860+
$tester = new ApplicationTester($application);
861+
862+
$tester->run(array('command' => 'foo'), array('decorated' => false));
863+
$this->assertContains('[InvalidArgumentException@anonymous]', $tester->getDisplay(true));
864+
865+
$application = new Application();
866+
$application->setAutoExit(false);
867+
$application->register('foo')->setCode(function () {
868+
throw new \InvalidArgumentException(sprintf('Dummy type "%s" is invalid.', \get_class(new class() {
869+
})));
870+
});
871+
$tester = new ApplicationTester($application);
872+
873+
$tester->run(array('command' => 'foo'), array('decorated' => false));
874+
$this->assertContains('Dummy type "@anonymous" is invalid.', $tester->getDisplay(true));
875+
}
876+
852877
public function testRun()
853878
{
854879
$application = new Application();

0 commit comments

Comments
 (0)