@@ -194,13 +194,10 @@ public function doRun(InputInterface $input, OutputInterface $output)
194194 }
195195
196196 try {
197- $ e = $ this ->runningCommand = null ;
197+ $ this ->runningCommand = null ;
198198 // the command name MUST be the first element of the input
199199 $ command = $ this ->find ($ name );
200- } catch (\Exception $ e ) {
201200 } catch (\Throwable $ e ) {
202- }
203- if (
6D40
null !== $ e ) {
204201 if (null !== $ this ->dispatcher ) {
205202 $ event = new ConsoleErrorEvent ($ input , $ output , $ e );
206203 $ this ->dispatcher ->dispatch (ConsoleEvents::ERROR , $ event );
@@ -813,24 +810,17 @@ protected function doRunCommand(Command $command, InputInterface $input, OutputI
813810 } else {
814811 $ exitCode = ConsoleCommandEvent::RETURN_CODE_DISABLED ;
815812 }
816- } catch (\Exception $ e ) {
817813 } catch (\Throwable $ e ) {
818- }
819- if (null !== $ e ) {
820814 $ event = new ConsoleErrorEvent ($ input , $ output , $ e , $ command );
821815 $ this ->dispatcher ->dispatch (ConsoleEvents::ERROR , $ event );
822816 $ e = $ event ->getError ();
823817
824- if (0 = == $ exitCode = $ event ->getExitCode ()) {
825- $ e = null ;
818+ if (0 ! == $ exitCode = $ event ->getExitCode ()) {
819+ throw $ e ;
826820 }
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 );
834824 }
835825
836826 return $ event ->getExitCode ();
0 commit comments