Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8f16615

Browse filesBrowse files
author
Hugo Fonseca
committed
[Console] rethrow the original exception
1 parent 93ae8c6 commit 8f16615
Copy full SHA for 8f16615

File tree

2 files changed

+20
-15
lines changed
Filter options

2 files changed

+20
-15
lines changed

‎src/Symfony/Component/Console/Application.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Application.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ protected function doRunCommand(Command $command, InputInterface $input, OutputI
866866
$event = new ConsoleTerminateEvent($command, $input, $output, $e->getCode());
867867
$this->dispatcher->dispatch(ConsoleEvents::TERMINATE, $event);
868868

869-
throw $e;
869+
throw $x;
870870
}
871871
} else {
872872
$exitCode = ConsoleCommandEvent::RETURN_CODE_DISABLED;

‎src/Symfony/Component/Console/Tests/ApplicationTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Tests/ApplicationTest.php
+19-14Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@ public function testRunWithDispatcher()
914914
}
915915

916916
/**
917-
* @expectedException \LogicException
917+
* @expectedException \RuntimeException
918918
* @expectedExceptionMessage caught
919919
*/
920920
public function testRunWithExceptionAndDispatcher()
@@ -925,7 +925,7 @@ public function testRunWithExceptionAndDispatcher()
925925
$application->setCatchExceptions(false);
926926

927927
$application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) {
928-
throw new \RuntimeException('foo');
928+
throw new \RuntimeException('caught');
929929
});
930930

931931
$tester = new ApplicationTester($application);
@@ -949,37 +949,42 @@ public function testRunDispatchesAllEventsWithException()
949949
$this->assertContains('before.foo.caught.after.', $tester->getDisplay());
950950
}
951951

952-
public function testRunDispatchesAllEventsWithError()
952+
/**
953+
* @expectedException \Error
954+
* @expectedExceptionMessage caught
955+
*/
956+
public function testRunWithErrorAndDispatcher()
953957
{
954958
$application = new Application();
955959
$application->setDispatcher($this->getDispatcher());
956960
$application->setAutoExit(false);
961+
$application->setCatchExceptions(false);
957962

958-
$application->register('dym')->setCode(function (InputInterface $input, OutputInterface $output) {
959-
$output->write('dym.');
960-
961-
throw new \Error('dymerr');
963+
$application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) {
964+
throw new \Error('caught');
962965
});
963966

964967
$tester = new ApplicationTester($application);
965-
$tester->run(array('command' => 'dym'));
966-
$this->assertContains('before.dym.caught.after.', $tester->getDisplay(), 'The PHP Error did not dispached events');
968+
$tester->run(array('command' => 'foo'));
967969
}
968970

971+
/**
972+
* @expectedException \Error
973+
* @expectedExceptionMessage caught
974+
*/
969975
public function testRunWithErrorFailingStatusCode()
970976
{
971977
$application = new Application();
972978
$application->setDispatcher($this->getDispatcher());
973979
$application->setAutoExit(false);
980+
$application->setCatchExceptions(false);
974981

975-
$application->register('dus')->setCode(function (InputInterface $input, OutputInterface $output) {
976-
$output->write('dus.');
977-
978-
throw new \Error('duserr');
982+
$application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) {
983+
throw new \Error('caught');
979984
});
980985

981986
$tester = new ApplicationTester($application);
982-
$tester->run(array('command' => 'dus'));
987+
$tester->run(array('command' => 'foo'));
983988
$this->assertSame(1, $tester->getStatusCode(), 'Status code should be 1');
984989
}
985990

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.