@@ -194,13 +194,10 @@ public function doRun(InputInterface $input, OutputInterface $output)
194
194
}
195
195
196
196
try {
197
- $ e = $ this ->runningCommand = null ;
197
+ $ this ->runningCommand = null ;
198
198
// the command name MUST be the first element of the input
199
199
$ command = $ this ->find ($ name );
200
- } catch (\Exception $ e ) {
201
200
} catch (\Throwable $ e ) {
202
- }
203
- if (null !== $ e ) {
204
201
if (null !== $ this ->dispatcher ) {
205
202
$ event = new ConsoleErrorEvent ($ input , $ output , $ e );
206
203
$ this ->dispatcher ->dispatch (ConsoleEvents::ERROR , $ event );
@@ -813,24 +810,17 @@ protected function doRunCommand(Command $command, InputInterface $input, OutputI
813
810
} else {
814
811
$ exitCode = ConsoleCommandEvent::RETURN_CODE_DISABLED ;
815
812
}
816
- } catch (\Exception $ e ) {
817
813
} catch (\Throwable $ e ) {
818
- }
819
- if (null !== $ e ) {
820
814
$ event = new ConsoleErrorEvent ($ input , $ output , $ e , $ command );
821
815
$ this ->dispatcher ->dispatch (ConsoleEvents::ERROR , $ event );
822
816
$ e = $ event ->getError ();
823
817
824
- if (0 = == $ exitCode = $ event ->getExitCode ()) {
825
- $ e = null ;
818
+ if (0 ! == $ exitCode = $ event ->getExitCode ()) {
819
+ throw $ e ;
826
820
}
827
- }
828
-
829
- $ event = new ConsoleTerminateEvent ($ command , $ input , $ output , $ exitCode );
830
- $ this ->dispatcher ->dispatch (ConsoleEvents::TERMINATE , $ event );
831
-
832
- if (null !== $ e ) {
833
- throw $ e ;
821
+ } finally {
822
+ $ event = new ConsoleTerminateEvent ($ command , $ input , $ output , $ exitCode );
823
+ $ this ->dispatcher ->dispatch (ConsoleEvents::TERMINATE , $ event );
834
824
}
835
825
836
826
return $ event ->getExitCode ();
0 commit comments