Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit8f16615

Browse files
author
Hugo Fonseca
committed
[Console] rethrow the original exception
1 parent93ae8c6 commit8f16615

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

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

Lines 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 =newConsoleTerminateEvent($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‎

Lines 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
publicfunctiontestRunWithExceptionAndDispatcher()
@@ -925,7 +925,7 @@ public function testRunWithExceptionAndDispatcher()
925925
$application->setCatchExceptions(false);
926926

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

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

952-
publicfunctiontestRunDispatchesAllEventsWithError()
952+
/**
953+
* @expectedException \Error
954+
* @expectedExceptionMessage caught
955+
*/
956+
publicfunctiontestRunWithErrorAndDispatcher()
953957
{
954958
$application =newApplication();
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-
thrownew \Error('dymerr');
963+
$application->register('foo')->setCode(function (InputInterface$input,OutputInterface$output) {
964+
thrownew \Error('caught');
962965
});
963966

964967
$tester =newApplicationTester($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
publicfunctiontestRunWithErrorFailingStatusCode()
970976
{
971977
$application =newApplication();
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-
thrownew \Error('duserr');
982+
$application->register('foo')->setCode(function (InputInterface$input,OutputInterface$output) {
983+
thrownew \Error('caught');
979984
});
980985

981986
$tester =newApplicationTester($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)

[8]ページ先頭

©2009-2025 Movatter.jp